Skip to content

Commit

Permalink
Define the required envvar on a per-test basis
Browse files Browse the repository at this point in the history
  • Loading branch information
JasperCraeghs committed Jan 26, 2024
1 parent 6719965 commit 62e5a26
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def setUp(self):
TEST_OUT_DIR.mkdir()

def tearDown(self):
for var in ('FIRST_ENVVAR', 'SECOND_ENVVAR'):
for var in ('FIRST_ENVVAR', 'SECOND_ENVVAR', 'MIN_SPHINX_WARNINGS', 'MAX_SPHINX_WARNINGS'):
if var in os.environ:
del os.environ[var]

Expand Down Expand Up @@ -132,6 +132,8 @@ def test_exact_with_max(self):
warnings_wrapper(['--junit', '--exact-warnings', '3', '--max-warnings', '3', 'tests/test_in/junit*.xml'])

def test_configfile_ok(self):
os.environ['MIN_SPHINX_WARNINGS'] = '0'
os.environ['MAX_SPHINX_WARNINGS'] = '0'
retval = warnings_wrapper(['--config', 'tests/test_in/config_example.json', 'tests/test_in/junit_single_fail.xml'])
self.assertEqual(0, retval)

Expand Down Expand Up @@ -304,6 +306,8 @@ def test_output_file_junit(self):

@patch('pathlib.Path.cwd')
def test_code_quality(self, path_cwd_mock):
os.environ['MIN_SPHINX_WARNINGS'] = '0'
os.environ['MAX_SPHINX_WARNINGS'] = '0'
path_cwd_mock.return_value = '/home/user/myproject'
filename = 'code_quality.json'
out_file = str(TEST_OUT_DIR / filename)
Expand All @@ -317,6 +321,8 @@ def test_code_quality(self, path_cwd_mock):
self.assertTrue(filecmp.cmp(out_file, ref_file), '{} differs from {}'.format(out_file, ref_file))

def test_code_quality_abspath_failure(self):
os.environ['MIN_SPHINX_WARNINGS'] = '0'
os.environ['MAX_SPHINX_WARNINGS'] = '0'
filename = 'code_quality.json'
out_file = str(TEST_OUT_DIR / filename)
with self.assertRaises(ValueError) as c_m:
Expand Down

0 comments on commit 62e5a26

Please sign in to comment.