Skip to content

Commit

Permalink
Make docstrings in unittests raw strings
Browse files Browse the repository at this point in the history
The \ for LaTeX commands was causing a syntax warning.
  • Loading branch information
christianp committed Sep 25, 2024
1 parent 537b27d commit f1e65a3
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 15 deletions.
8 changes: 5 additions & 3 deletions unittests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
import tempfile

class ChirunCompilationTest(unittest.TestCase):
""" A unit test which compiles a Chirun package.
r"""
A unit test which compiles a Chirun package.
The files in the ``source_path`` are copied to a temporary directory before being compiled.
Run with the environment variable ``KEEP_TEST_OUTPUT=1`` to preserve the contents of the temporary directory, under ``unittests/_kept``
"""
Expand Down Expand Up @@ -72,7 +73,7 @@ def tearDownClass(cls):
cls.tmpdir.cleanup()

def get_soup(self, path):
"""
r"""
Get a BeautifulSoup instance for the given HTML file in the build directory.
"""

Expand All @@ -85,7 +86,8 @@ def get_manifest(self):
return json.load(fp)

class ExpectCrashTest(ChirunCompilationTest):
""" A test case which expects Chirun to quit with an error.
r"""
A test case which expects Chirun to quit with an error.
"""

show_stderr = False
Expand Down
6 changes: 4 additions & 2 deletions unittests/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ def test_structure(self):
self.assertEqual([x['type'] for x in manifest['structure']], ['introduction', 'chapter', 'chapter'], msg="There is an introduction and two chapters.")

def test_empty_links(self):
""" Check that all links on the introduction page contain readable text.
"""
Check that all links on the introduction page contain readable text.
Tests https://github.com/chirun-ncl/chirun/issues/12
"""
Expand All @@ -62,7 +63,8 @@ def test_empty_links(self):
self.assertFalse(any(a.text == '' for a in intro.find_all('a')), msg='All links contain text')

def test_file_build_time(self):
""" Check that URLs of static files have a ``build_time`` query parameter added, to prevent caching.
"""
Check that URLs of static files have a ``build_time`` query parameter added, to prevent caching.
Tests https://github.com/chirun-ncl/chirun/issues/199
"""
Expand Down
3 changes: 2 additions & 1 deletion unittests/ifplastex.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ class IfplastexTest(ChirunCompilationTest):
compile_args = ['-f','test.tex']

def test_ifplastex(self):
""" Test that the ``\ifplastex`` and ``\ifpdflatex`` commands are defined and work as expected.
r"""
Test that the ``\ifplastex`` and ``\ifpdflatex`` commands are defined and work as expected.
Tests https://github.com/chirun-ncl/chirun/issues/124
"""
Expand Down
3 changes: 2 additions & 1 deletion unittests/placeins.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ class PlaceinsTest(ChirunCompilationTest):
compile_args = ['-f','test.tex', '--no-pdf']

def test_floatbarrier(self):
""" The ``\FloatBarrier`` command shouldn't stop HTML output from working'
r"""
The ``\FloatBarrier`` command shouldn't stop HTML output from working'
Tests https://github.com/chirun-ncl/chirun/issues/164
"""
Expand Down
3 changes: 2 additions & 1 deletion unittests/slash.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ class SlashTest(ChirunCompilationTest):
compile_args = ['-f', 'test.tex', '--no-pdf']

def test_slash(self):
""" Check that the ``\slash`` command is interpreted and produces a forward slash character.
r"""
Check that the ``\slash`` command is interpreted and produces a forward slash character.
Tests https://github.com/chirun-ncl/chirun/issues/211
"""
Expand Down
18 changes: 12 additions & 6 deletions unittests/slides.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ class SlidesTest(ChirunCompilationTest):
source_path = 'slides'

def test_beamer_slides_author(self):
""" Test that the author field for the slides item is used, instead of the package's author.
r"""
Test that the author field for the slides item is used, instead of the package's author.
Tests https://github.com/chirun-ncl/chirun/issues/14
"""
Expand All @@ -14,7 +15,8 @@ def test_beamer_slides_author(self):
self.assertEqual(soup.select_one('#title-slide .author').text, 'A.N. Other')

def test_beamer_slide_title(self):
""" Test that a frame with a given title has that title displayed in the HTML slides version.
r"""
Test that a frame with a given title has that title displayed in the HTML slides version.
Tests https://github.com/chirun-ncl/chirun/issues/28
"""
Expand All @@ -25,7 +27,8 @@ def test_beamer_slide_title(self):
self.assertEqual(soup.select('.beamer-frame')[3].select_one('.beamer-frame-title').text, 'Title as param')

def test_beamer_slides_tableofcontents(self):
""" Test that a table of contents is produced, with a link to each section.
r"""
Test that a table of contents is produced, with a link to each section.
Tests https://github.com/chirun-ncl/chirun/issues/48
"""
Expand All @@ -38,7 +41,8 @@ def test_beamer_slides_tableofcontents(self):
self.assertEqual(contents_slide.select_one('a').text.strip(), 'Section')

def test_beamer_loads_hyperref(self):
""" Test that the beamer documentclass loads the hyperref package.
r"""
Test that the beamer documentclass loads the hyperref package.
Tests https://github.com/chirun-ncl/chirun/issues/103
"""
Expand All @@ -51,15 +55,17 @@ def test_beamer_loads_hyperref(self):
self.assertEqual(a.text, 'Example')

def test_appendixnumberbeamer(self):
""" Test that the appendixnumberbeamer package loads.
r"""
Test that the appendixnumberbeamer package loads.
Tests https://github.com/chirun-ncl/chirun/issues/40
"""

self.assertTrue((self.build_dir / 'appendix_number' / 'index.html').exists())

def test_pause(self):
""" The \pause command is removed from any math expressions.
r"""
The \pause command is removed from any math expressions.
Tests https://github.com/chirun-ncl/chirun/issues/58
"""
Expand Down
3 changes: 2 additions & 1 deletion unittests/verbatim.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ class VerbatimTest(ChirunCompilationTest):
compile_args = ['-f', 'test.tex', '--no-pdf']

def test_comment_environment(self):
""" Check that you can define a new environment which wraps a \comment command.
r"""
Check that you can define a new environment which wraps a \comment command.
Tests https://github.com/chirun-ncl/chirun/issues/87
"""
Expand Down

0 comments on commit f1e65a3

Please sign in to comment.