Skip to content

Commit 8af2406

Browse files
committed
MAINT: run pyupgrade for dropping 3.7
1 parent 1c222a5 commit 8af2406

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

pytest_arraydiff/plugin.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
abstractclassmethod = abc.abstractclassmethod
4444

4545

46-
class BaseDiff(object, metaclass=abc.ABCMeta):
46+
class BaseDiff(metaclass=abc.ABCMeta):
4747

4848
@abstractstaticmethod
4949
def read(filename):
@@ -83,8 +83,8 @@ def compare(cls, reference_file, test_file, atol=None, rtol=None):
8383
try:
8484
np.testing.assert_allclose(array_ref, array_new, atol=atol, rtol=rtol)
8585
except AssertionError as exc:
86-
message = "\n\na: {0}".format(test_file) + '\n'
87-
message += "b: {0}".format(reference_file) + '\n'
86+
message = f"\n\na: {test_file}" + '\n'
87+
message += f"b: {reference_file}" + '\n'
8888
message += exc.args[0]
8989
return False, message
9090
else:
@@ -160,8 +160,8 @@ def compare(cls, reference_file, test_file, atol=None, rtol=None):
160160
try:
161161
pdt.assert_frame_equal(ref_data, test_data)
162162
except AssertionError as exc:
163-
message = "\n\na: {0}".format(test_file) + '\n'
164-
message += "b: {0}".format(reference_file) + '\n'
163+
message = f"\n\na: {test_file}" + '\n'
164+
message += f"b: {reference_file}" + '\n'
165165
message += exc.args[0]
166166
return False, message
167167
else:
@@ -251,7 +251,7 @@ def wrapper(*args, **kwargs):
251251
item.obj = array_interceptor(plugin, item.obj)
252252

253253

254-
class ArrayComparison(object):
254+
class ArrayComparison:
255255

256256
def __init__(self, config, reference_dir=None, generate_dir=None, default_format='text'):
257257
self.config = config
@@ -272,7 +272,7 @@ def pytest_runtest_call(self, item):
272272
file_format = compare.kwargs.get('file_format', self.default_format)
273273

274274
if file_format not in FORMATS:
275-
raise ValueError("Unknown format: {0}".format(file_format))
275+
raise ValueError(f"Unknown format: {file_format}")
276276

277277
if 'extension' in compare.kwargs:
278278
extension = compare.kwargs['extension']

tests/test_pytest_arraydiff.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def test_succeeds_func_fits_hdu():
4040
return fits.PrimaryHDU(np.arange(3 * 5).reshape((3, 5)).astype(np.int64))
4141

4242

43-
class TestClass(object):
43+
class TestClass:
4444

4545
@pytest.mark.array_compare(file_format='fits', reference_dir=reference_dir)
4646
def test_succeeds_class(self):
@@ -66,11 +66,11 @@ def test_fails():
6666
f.write(TEST_FAILING)
6767

6868
# If we use --arraydiff, it should detect that the file is missing
69-
code = subprocess.call('pytest --arraydiff {0}'.format(test_file), shell=True)
69+
code = subprocess.call(f'pytest --arraydiff {test_file}', shell=True)
7070
assert code != 0
7171

7272
# If we don't use --arraydiff option, the test should succeed
73-
code = subprocess.call('pytest {0}'.format(test_file), shell=True)
73+
code = subprocess.call(f'pytest {test_file}', shell=True)
7474
assert code == 0
7575

7676

@@ -102,7 +102,7 @@ def test_generate(file_format):
102102
assert b'File not found for comparison test' in grepexc.output
103103

104104
# If we do generate, the test should succeed and a new file will appear
105-
code = subprocess.call(['pytest', '--arraydiff-generate-path={0}'.format(gen_dir), test_file],
105+
code = subprocess.call(['pytest', f'--arraydiff-generate-path={gen_dir}', test_file],
106106
timeout=10)
107107
assert code == 0
108108
assert os.path.exists(os.path.join(gen_dir, 'test_gen.' + ('fits' if file_format == 'fits' else 'txt')))
@@ -130,8 +130,8 @@ def test_default_format(file_format):
130130
gen_dir = os.path.join(tmpdir, 'spam', 'egg')
131131

132132
# If we do generate, the test should succeed and a new file will appear
133-
code = subprocess.call('pytest -s --arraydiff-default-format={0}'
134-
' --arraydiff-generate-path={1} {2}'.format(file_format, gen_dir, test_file), shell=True)
133+
code = subprocess.call('pytest -s --arraydiff-default-format={}'
134+
' --arraydiff-generate-path={} {}'.format(file_format, gen_dir, test_file), shell=True)
135135
assert code == 0
136136
assert os.path.exists(os.path.join(gen_dir, 'test_default.' + ('fits' if file_format == 'fits' else 'txt')))
137137

0 commit comments

Comments
 (0)