Mercurial > p > roundup > code
comparison test/test_config.py @ 7913:6102ae426390
issue2551334 - get test suite running under windows
Support windows style filepaths.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sun, 28 Apr 2024 09:17:54 -0400 |
| parents | 011941fcb598 |
| children | 1e38ca6fb16e |
comparison
equal
deleted
inserted
replaced
| 7912:5b47966bf6f0 | 7913:6102ae426390 |
|---|---|
| 21 import os | 21 import os |
| 22 import pytest | 22 import pytest |
| 23 import shutil | 23 import shutil |
| 24 import sys | 24 import sys |
| 25 import unittest | 25 import unittest |
| 26 | |
| 27 from os.path import normpath | |
| 26 | 28 |
| 27 from roundup import configuration | 29 from roundup import configuration |
| 28 from roundup.backends import get_backend, have_backend | 30 from roundup.backends import get_backend, have_backend |
| 29 from roundup.hyperdb import DatabaseError | 31 from roundup.hyperdb import DatabaseError |
| 30 | 32 |
| 216 | 218 |
| 217 | 219 |
| 218 def testStaticFiles(self): | 220 def testStaticFiles(self): |
| 219 config = configuration.CoreConfig() | 221 config = configuration.CoreConfig() |
| 220 | 222 |
| 223 | |
| 224 if ("/tmp/bar" == normpath("/tmp/bar/")): | |
| 225 result_list = ["./foo", "/tmp/bar"] | |
| 226 else: | |
| 227 result_list = [".\\foo", "\\tmp\\bar"] | |
| 221 self.assertEqual(None, | 228 self.assertEqual(None, |
| 222 config._get_option('STATIC_FILES').set("foo /tmp/bar")) | 229 config._get_option('STATIC_FILES').set("foo /tmp/bar")) |
| 223 | 230 print(config.STATIC_FILES) |
| 224 self.assertEqual(config.STATIC_FILES, | 231 self.assertEqual(config.STATIC_FILES, result_list) |
| 225 ["./foo", "/tmp/bar"]) | |
| 226 | |
| 227 self.assertEqual(config['STATIC_FILES'], | |
| 228 ["./foo", "/tmp/bar"]) | |
| 229 | 232 |
| 230 def testIsolationLevel(self): | 233 def testIsolationLevel(self): |
| 231 config = configuration.CoreConfig() | 234 config = configuration.CoreConfig() |
| 232 | 235 |
| 233 self.assertEqual(None, | 236 self.assertEqual(None, |
| 980 with self.assertRaises(configuration.ParsingOptionError) as cm: | 983 with self.assertRaises(configuration.ParsingOptionError) as cm: |
| 981 config.load(self.dirname) | 984 config.load(self.dirname) |
| 982 | 985 |
| 983 print(cm.exception) | 986 print(cm.exception) |
| 984 self.assertIn("'%' must be followed by '%' or '(', found: '% is invalid'", cm.exception.args[0]) | 987 self.assertIn("'%' must be followed by '%' or '(', found: '% is invalid'", cm.exception.args[0]) |
| 985 self.assertIn("_test_instance/config.ini with section [main] at option admin_email", cm.exception.args[0]) | 988 self.assertIn(normpath("_test_instance/config.ini") + " with section [main] at option admin_email", cm.exception.args[0]) |
| 986 | 989 |
| 987 | 990 |
| 988 from roundup.admin import AdminTool | 991 from roundup.admin import AdminTool |
| 989 from .test_admin import captured_output | 992 from .test_admin import captured_output |
| 990 | 993 |
| 991 admin=AdminTool() | 994 admin=AdminTool() |
| 992 with captured_output() as (out, err): | 995 with captured_output() as (out, err): |
| 993 sys.argv=['main', '-i', self.dirname, 'get', 'tile', 'issue1'] | 996 sys.argv=['main', '-i', self.dirname, 'get', 'tile', 'issue1'] |
| 994 ret = admin.main() | 997 ret = admin.main() |
| 995 | 998 |
| 996 expected_err = "Error in _test_instance/config.ini with section [main] at option admin_email: '%' must be followed by '%' or '(', found: '% is invalid'" | 999 expected_err = ("Error in " + |
| 1000 normpath("_test_instance/config.ini") + | |
| 1001 " with section [main] at option admin_email: '%' " | |
| 1002 "must be followed by '%' or '(', found: " | |
| 1003 "'% is invalid'") | |
| 997 | 1004 |
| 998 self.assertEqual(ret, 1) | 1005 self.assertEqual(ret, 1) |
| 999 out = out.getvalue().strip() | 1006 out = out.getvalue().strip() |
| 1000 self.assertEqual(out, expected_err) | 1007 self.assertEqual(out, expected_err) |
| 1001 | 1008 |
