Skip to content

Commit

Permalink
renamed assertEqual to assert_equal
Browse files Browse the repository at this point in the history
  • Loading branch information
ewu63 committed Feb 7, 2022
1 parent ede6694 commit 84fe7ed
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions baseclasses/testing/assertions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
DEFAULT_TOL = 1e-12


def assertEqual(a, b):
def assert_equal(a, b):
"""
This replaces the assertEqual functionality provided by unittest.TestCase
so that we can call this outside the class
Expand All @@ -17,7 +17,7 @@ def assertEqual(a, b):
if set(a.keys()) != set(b.keys()):
raise AssertionError("The two dictionaries do not have the same keys")
for k in a.keys():
assertEqual(a[k], b[k])
assert_equal(a[k], b[k])
elif not a == b:
raise AssertionError(f"{a} and {b} are not equal.")

Expand Down Expand Up @@ -63,7 +63,7 @@ def assert_dict_not_allclose(actual, desired, atol=DEFAULT_TOL, rtol=DEFAULT_TOL
"""
The opposite of assert_dict_allclose
"""
assertEqual(set(actual.keys()), set(desired.keys()))
assert_equal(set(actual.keys()), set(desired.keys()))
for key in actual.keys():
if np.allclose(actual[key], desired[key], atol=atol, rtol=rtol):
raise AssertionError(f"Dictionaries are close! Got {actual} and {desired} for key {key}")
Expand Down
6 changes: 3 additions & 3 deletions tests/test_fileIO.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
from parameterized import parameterized
from baseclasses.testing.decorators import require_mpi
from baseclasses.testing.assertions import assertEqual
from baseclasses.testing.assertions import assert_equal
from baseclasses.utils import readPickle, writePickle, readJSON, writeJSON
import numpy as np

Expand Down Expand Up @@ -35,7 +35,7 @@ def test_pickle(self, name, obj):
self.fileName = f"{name}.pkl"
writePickle(self.fileName, obj, comm=self.comm)
newObj = readPickle(self.fileName, comm=self.comm)
assertEqual(obj, newObj)
assert_equal(obj, newObj)

@parameterized.expand(
[
Expand All @@ -48,7 +48,7 @@ def test_JSON(self, name, obj):
self.fileName = f"{name}.json"
writeJSON(self.fileName, obj, comm=self.comm)
newObj = readJSON(self.fileName, comm=self.comm)
assertEqual(obj, newObj)
assert_equal(obj, newObj)

def tearDown(self):
if self.comm.rank == 0:
Expand Down

0 comments on commit 84fe7ed

Please sign in to comment.