|
4 | 4 | from pathlib import Path |
5 | 5 | import sys |
6 | 6 | import textwrap |
7 | | -from unittest import TestCase |
8 | 7 |
|
9 | 8 | if sys.version_info >= (3, 11): |
10 | 9 | import tomllib |
@@ -108,24 +107,22 @@ def test_BUGWARRIORRC_empty(self): |
108 | 107 | assert load.get_config_path() == rc |
109 | 108 |
|
110 | 109 |
|
111 | | -class TestBugwarriorConfigParser(TestCase): |
112 | | - def setUp(self): |
113 | | - self.config = load.BugwarriorConfigParser() |
114 | | - self.config['general'] = { |
115 | | - 'someint': '4', |
116 | | - 'somenone': '', |
117 | | - 'somechar': 'somestring', |
118 | | - } |
| 110 | +class TestBugwarriorConfigParser: |
| 111 | + @pytest.fixture |
| 112 | + def config(self): |
| 113 | + config = load.BugwarriorConfigParser() |
| 114 | + config['general'] = {'someint': '4', 'somenone': '', 'somechar': 'somestring'} |
| 115 | + return config |
119 | 116 |
|
120 | | - def test_getint(self): |
121 | | - assert self.config.getint('general', 'someint') == 4 |
| 117 | + def test_getint(self, config): |
| 118 | + assert config.getint('general', 'someint') == 4 |
122 | 119 |
|
123 | | - def test_getint_none(self): |
124 | | - assert self.config.getint('general', 'somenone') is None |
| 120 | + def test_getint_none(self, config): |
| 121 | + assert config.getint('general', 'somenone') is None |
125 | 122 |
|
126 | | - def test_getint_valueerror(self): |
| 123 | + def test_getint_valueerror(self, config): |
127 | 124 | with pytest.raises(ValueError): |
128 | | - self.config.getint('general', 'somechar') |
| 125 | + config.getint('general', 'somechar') |
129 | 126 |
|
130 | 127 |
|
131 | 128 | class TestParseFile(LoadTest): |
|
0 commit comments