Skip to content

Commit

Permalink
Merge 6228ead into 6591015
Browse files Browse the repository at this point in the history
  • Loading branch information
whart222 committed Mar 12, 2020
2 parents 6591015 + 6228ead commit 66d86b4
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions pyutilib/misc/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ def _display(obj, *args):
class Test(unittest.TestCase):

def setUp(self):
# Save the original environment, then force a fixed column width
# so tests do not fail on some platforms (notably, OSX)
self.original_environ = dict(os.environ)
os.environ["COLUMNS"] = "80"

self.config = config = ConfigBlock(
"Basic configuration for Flushing models", implicit=True)
net = config.declare('network', ConfigBlock())
Expand Down Expand Up @@ -148,6 +153,9 @@ def setUp(self):
},
},
}
def tearDown(self):
# Restore the original environment
os.environ = self.original_environ

# Utility method for generating and validating a template description
def _validateTemplate(self, config, reference_template, **kwds):
Expand Down Expand Up @@ -892,7 +900,7 @@ def test_generate_documentation(self):
test = self.config.generate_documentation()
OUTPUT.write(test)
OUTPUT.close()
print(test)
#print(test)
self.assertFalse(
pyutilib.misc.comparison.compare_file(oFile, oFile[:-4] + '.txt')[
0])
Expand Down Expand Up @@ -1011,7 +1019,7 @@ def test_generate_custom_documentation(self):
item_body= "item{%s}\n",
item_end= "endItem{%s}\n",
)
print(test)
#print(test)
self.assertEqual(test, reference)

test = self.config.generate_documentation(
Expand All @@ -1027,7 +1035,7 @@ def test_generate_custom_documentation(self):
stripped_reference = re.sub('\{[^\}]*\}','',reference)
else:
stripped_reference = re.sub('\{[^\}]*\}','',reference,flags=re.M)
print(test)
#print(test)
self.assertEqual(test, stripped_reference)

def test_block_get(self):
Expand Down Expand Up @@ -1165,7 +1173,7 @@ def test_block_items(self):
self.assertFalse(itemiter is self.config['scenario'].iteritems())

def test_value(self):
print(self.config.value())
#print(self.config.value())
self.assertEqual(self._reference, self.config.value())

def test_list_manipulation(self):
Expand Down Expand Up @@ -1283,7 +1291,7 @@ def test_argparse_help(self):
parser = argparse.ArgumentParser(prog='tester')
self.config.initialize_argparse(parser)
help = parser.format_help()
print(help)
#print(help)
self.assertEqual(
"""usage: tester [-h] [--epanet-file EPANET] [--scenario-file STR] [--merlion]
Expand All @@ -1308,7 +1316,8 @@ def test_argparse_help_implicit_disable(self):
parser = argparse.ArgumentParser(prog='tester')
self.config.initialize_argparse(parser)
help = parser.format_help()
print(help)
#print(help)
self.maxDiff = None
self.assertEqual(
"""usage: tester [-h] [--epanet-file EPANET] [--scenario-file STR] [--merlion]
[--disable-epanet]
Expand Down Expand Up @@ -1380,7 +1389,7 @@ def test_argparse_subparsers(self):
self.config.initialize_argparse(parser)

help = parser.format_help()
print(help)
#print(help)
self.assertEqual(
"""usage: tester [-h] [--epanet-file EPANET] [--scenario-file STR] [--merlion]
{flushing} ...
Expand All @@ -1399,7 +1408,7 @@ def test_argparse_subparsers(self):
""", help)

help = subp.format_help()
print(help)
#print(help)
self.assertEqual(
"""usage: tester flushing [-h] [--feasible-nodes STR] [--infeasible-nodes STR]
[--duration FLOAT]
Expand Down

0 comments on commit 66d86b4

Please sign in to comment.