Package: pypandoc / 1.4+ds0-1.1

0004-Workaround-a-problem-with-uppercase-lua-filenames-in-pandoc.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
From 0d12f7d04eb746e41241657afcdb38ebe0af7e0d Mon Sep 17 00:00:00 2001
From: Jan Schulz <jasc@gmx.net>
Date: Sun, 29 Apr 2018 19:03:18 +0200
Subject: [PATCH] Workaround a problem with uppercase lua filenames in pandoc

---
 tests.py | 39 ++++++++++++++++++++++++---------------
 1 file changed, 24 insertions(+), 15 deletions(-)

--- a/tests.py
+++ b/tests.py
@@ -16,19 +16,27 @@
 
 
 @contextlib.contextmanager
-def closed_tempfile(suffix, text=None, dir_name=None):
-    if dir_name:
-        dir_name = tempfile.mkdtemp(suffix=dir_name)
-    with tempfile.NamedTemporaryFile('w+t', suffix=suffix, delete=False, dir=dir_name) as test_file:
-        file_name = test_file.name
-        if text:
-            test_file.write(text)
-            test_file.flush()
-    yield file_name
-    if dir_name:
-        shutil.rmtree(dir_name, ignore_errors=True)
-    else:
-        os.remove(file_name)
+def closed_tempfile(suffix, text=None, dir_name=None, check_case=False):
+    file_name = None
+    try:
+        if dir_name:
+            dir_name = tempfile.mkdtemp(suffix=dir_name)
+
+        with tempfile.NamedTemporaryFile('w+t', suffix=suffix, delete=False, dir=dir_name) as test_file:
+            file_name = test_file.name
+            if text:
+                test_file.write(text)
+                test_file.flush()
+        if check_case and file_name != file_name.lower():
+            # there is a bug in pandoc which can't work with uppercase lua files
+            # https://github.com/jgm/pandoc/issues/4610
+            raise unittest.SkipTest("pandoc has problems with uppercase filenames, got %s" % file_name)
+        yield file_name
+    finally:
+        if dir_name:
+            shutil.rmtree(dir_name, ignore_errors=True)
+        elif file_name:
+            os.remove(file_name)
 
 
 # Stolen from pandas
@@ -177,7 +185,8 @@
     def test_convert_with_custom_writer(self):
         lua_file_content = self.create_sample_lua()
         with closed_tempfile('.md', text='# title\n') as file_name:
-            with closed_tempfile('.lua', text=lua_file_content, dir_name="foo-bar+baz") as lua_file_name:
+            with closed_tempfile('.lua', text=lua_file_content, dir_name="foo-bar+baz",
+                                 check_case=True) as lua_file_name:
                 expected = u'<h1 id="title">title</h1>{0}'.format(os.linesep)
                 received = pypandoc.convert_file(file_name, lua_file_name)
                 self.assertEqualExceptForNewlineEnd(expected, received)