Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set maxDiff=None on the base TestCase class #3171

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions pyomo/common/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2098,7 +2098,6 @@ def test_generate_custom_documentation(self):
"generate_documentation is deprecated.",
LOG,
)
self.maxDiff = None
# print(test)
self.assertEqual(test, reference)

Expand All @@ -2113,7 +2112,6 @@ def test_generate_custom_documentation(self):
)
)
self.assertEqual(LOG.getvalue(), "")
self.maxDiff = None
# print(test)
self.assertEqual(test, reference)

Expand Down Expand Up @@ -2159,7 +2157,6 @@ def test_generate_custom_documentation(self):
"generate_documentation is deprecated.",
LOG,
)
self.maxDiff = None
# print(test)
self.assertEqual(test, reference)

Expand Down Expand Up @@ -2577,7 +2574,6 @@ def test_argparse_help_implicit_disable(self):
parser = argparse.ArgumentParser(prog='tester')
self.config.initialize_argparse(parser)
help = parser.format_help()
self.maxDiff = None
self.assertIn(
"""
-h, --help show this help message and exit
Expand Down Expand Up @@ -3106,8 +3102,6 @@ def test_declare_from(self):
cfg2.declare_from({})

def test_docstring_decorator(self):
self.maxDiff = None

@document_kwargs_from_configdict('CONFIG')
class ExampleClass(object):
CONFIG = ExampleConfig()
Expand Down
1 change: 0 additions & 1 deletion pyomo/common/tests/test_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,6 @@ def test_verbatim(self):
"\n"
" quote block\n"
)
self.maxDiff = None
self.assertEqual(self.stream.getvalue(), ans)


Expand Down
4 changes: 0 additions & 4 deletions pyomo/common/tests/test_timing.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ def test_report_timing(self):
m.y = Var(Any, dense=False)
xfrm.apply_to(m)
result = out.getvalue().strip()
self.maxDiff = None
for l, r in zip(result.splitlines(), ref.splitlines()):
self.assertRegex(str(l.strip()), str(r.strip()))
finally:
Expand All @@ -122,7 +121,6 @@ def test_report_timing(self):
m.y = Var(Any, dense=False)
xfrm.apply_to(m)
result = os.getvalue().strip()
self.maxDiff = None
for l, r in zip(result.splitlines(), ref.splitlines()):
self.assertRegex(str(l.strip()), str(r.strip()))
finally:
Expand All @@ -135,7 +133,6 @@ def test_report_timing(self):
m.y = Var(Any, dense=False)
xfrm.apply_to(m)
result = os.getvalue().strip()
self.maxDiff = None
for l, r in zip(result.splitlines(), ref.splitlines()):
self.assertRegex(str(l.strip()), str(r.strip()))
self.assertEqual(buf.getvalue().strip(), "")
Expand Down Expand Up @@ -172,7 +169,6 @@ def test_report_timing_context_manager(self):
xfrm.apply_to(m)
self.assertEqual(OUT.getvalue(), "")
result = OS.getvalue().strip()
self.maxDiff = None
for l, r in zip_longest(result.splitlines(), ref.splitlines()):
self.assertRegex(str(l.strip()), str(r.strip()))
# Active reporting is False: the previous log should not have changed
Expand Down
4 changes: 4 additions & 0 deletions pyomo/common/unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,10 @@ class TestCase(_unittest.TestCase):

__doc__ += _unittest.TestCase.__doc__

# By default, we always want to spend the time to create the full
# diff of the test reault and the baseline
maxDiff = None

def assertStructuredAlmostEqual(
self,
first,
Expand Down
1 change: 0 additions & 1 deletion pyomo/core/tests/unit/test_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -2667,7 +2667,6 @@ def test_pprint(self):

5 Declarations: a1_IDX a3_IDX c a b
"""
self.maxDiff = None
self.assertEqual(ref, buf.getvalue())

@unittest.skipIf(not 'glpk' in solvers, "glpk solver is not available")
Expand Down
1 change: 0 additions & 1 deletion pyomo/core/tests/unit/test_numeric_expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1424,7 +1424,6 @@ def test_sumOf_nestedTrivialProduct2(self):
e1 = m.a * m.p
e2 = m.b - m.c
e = e2 - e1
self.maxDiff = None
self.assertExpressionsEqual(
e,
LinearExpression(
Expand Down
2 changes: 0 additions & 2 deletions pyomo/core/tests/unit/test_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -1280,7 +1280,6 @@ def test_contains_with_nonflattened(self):
normalize_index.flatten = _old_flatten

def test_pprint_nonfinite_sets(self):
self.maxDiff = None
m = ConcreteModel()
m.v = Var(NonNegativeIntegers, dense=False)
m.ref = Reference(m.v)
Expand Down Expand Up @@ -1322,7 +1321,6 @@ def test_pprint_nonfinite_sets(self):

def test_pprint_nonfinite_sets_ctypeNone(self):
# test issue #2039
self.maxDiff = None
m = ConcreteModel()
m.v = Var(NonNegativeIntegers, dense=False)
m.ref = Reference(m.v, ctype=None)
Expand Down
1 change: 0 additions & 1 deletion pyomo/core/tests/unit/test_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -6267,7 +6267,6 @@ def test_issue_835(self):

@unittest.skipIf(NamedTuple is None, "typing module not available")
def test_issue_938(self):
self.maxDiff = None
NodeKey = NamedTuple('NodeKey', [('id', int)])
ArcKey = NamedTuple('ArcKey', [('node_from', NodeKey), ('node_to', NodeKey)])

Expand Down
1 change: 0 additions & 1 deletion pyomo/repn/tests/ampl/test_nlv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,6 @@ def test_log_timing(self):
m.c1 = Constraint([1, 2], rule=lambda m, i: sum(m.x.values()) == 1)
m.c2 = Constraint(expr=m.p * m.x[1] ** 2 + m.x[2] ** 3 <= 100)

self.maxDiff = None
OUT = io.StringIO()
with capture_output() as LOG:
with report_timing(level=logging.DEBUG):
Expand Down