Mercurial > p > roundup > code
comparison test/test_demo.py @ 7583:4cfaddc2d53e
test: do not run jinja2 demo test if jinja2 missing.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Mon, 24 Jul 2023 18:05:48 -0400 |
| parents | 77eb1a41fc06 |
| children | 227aca44fea5 |
comparison
equal
deleted
inserted
replaced
| 7582:978285986b2c | 7583:4cfaddc2d53e |
|---|---|
| 1 import pytest | |
| 1 import unittest | 2 import unittest |
| 2 import os, sys, shutil | 3 import os, sys, shutil |
| 3 | 4 |
| 4 from roundup.demo import install_demo, run_demo | 5 from roundup.demo import install_demo, run_demo |
| 5 | 6 |
| 20 try: | 21 try: |
| 21 sys.stdout, sys.stderr = new_out, new_err | 22 sys.stdout, sys.stderr = new_out, new_err |
| 22 yield sys.stdout, sys.stderr | 23 yield sys.stdout, sys.stderr |
| 23 finally: | 24 finally: |
| 24 sys.stdout, sys.stderr = old_out, old_err | 25 sys.stdout, sys.stderr = old_out, old_err |
| 26 | |
| 27 try: | |
| 28 import jinja2 | |
| 29 skip_jinja2 = lambda func, *args, **kwargs: func | |
| 30 except ImportError: | |
| 31 from .pytest_patcher import mark_class | |
| 32 skip_jinja2 = mark_class(pytest.mark.skip( | |
| 33 reason='Skipping Jinja2 tests: jinja2 library not available')) | |
| 25 | 34 |
| 26 class TestDemo(unittest.TestCase): | 35 class TestDemo(unittest.TestCase): |
| 27 def setUp(self): | 36 def setUp(self): |
| 28 self.home = os.path.abspath('_test_demo') | 37 self.home = os.path.abspath('_test_demo') |
| 29 | 38 |
| 71 self.run_install_demo("classic") | 80 self.run_install_demo("classic") |
| 72 | 81 |
| 73 def testDemoMinimal(self): | 82 def testDemoMinimal(self): |
| 74 self.run_install_demo('../templates/minimal', db="sqlite") | 83 self.run_install_demo('../templates/minimal', db="sqlite") |
| 75 | 84 |
| 85 @skip_jinja2 | |
| 76 def testDemoJinja(self): | 86 def testDemoJinja(self): |
| 77 self.run_install_demo('jinja2', db="anydbm") | 87 self.run_install_demo('jinja2', db="anydbm") |
| 78 | 88 |
| 79 # verify that template was set to jinja2 by reading config | 89 # verify that template was set to jinja2 by reading config |
| 80 with open(self.home + "/config.ini", "r") as f: | 90 with open(self.home + "/config.ini", "r") as f: |
