Skip to content

Commit

Permalink
Merge 3186c45 into cc1a617
Browse files Browse the repository at this point in the history
  • Loading branch information
whart222 committed Apr 8, 2019
2 parents cc1a617 + 3186c45 commit d02e0f6
Show file tree
Hide file tree
Showing 26 changed files with 57 additions and 23 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
27 changes: 27 additions & 0 deletions pyutilib/component/loader/tests/eggsrc/update
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh

cd pkg1
python setup.py sdist bdist_egg

cd ../pkg2
python setup.py sdist bdist_egg

cd ../pkg3
python setup.py sdist bdist_egg

cd ../pkg4
python setup.py sdist bdist_egg

cd ../pkg5
python setup.py sdist bdist_egg

cd ../pkg6
python setup.py sdist bdist_egg

cd ../pkg7
python setup.py sdist bdist_egg

cd ..
cp pkg[1-2]/dist/P*egg ../eggs1
cp pkg[3-7]/dist/P*egg ../eggs2

16 changes: 10 additions & 6 deletions pyutilib/component/loader/tests/test_egg.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@
yaml_available = False


@unittest.skipIf(not pkg_resources_avail, "Cannot import 'pkg_resources'")
class Test(pyutilib.th.TestCase):

def test_egg1(self):
"""Load an egg for the 'project1' project. Eggs are loaded in the 'eggs1' directory, but only the Project1 stuff is actually imported."""
#
# Load an egg for the 'project1' project.
# Eggs are loaded in the 'eggs1' directory, but only the Project1 stuff is actually imported.
#
pyutilib.subprocess.run(
[sys.executable, currdir + os.sep + "egg1.py", currdir, "json"])
self.assertMatchesJsonBaseline(currdir + "egg1.out",
Expand All @@ -37,7 +41,11 @@ def test_egg1(self):
currdir + "egg1.yml")

def test_egg2(self):
"""Load an egg for the 'project1' project. Eggs are loaded in the 'eggs1' and 'eggs2' directories, but only the Project1 and Project 3 stuff is actually imported."""
#
# Load an egg for the 'project1' project.
# Eggs are loaded in the 'eggs1' and 'eggs2' directories, but only the
# Project1 and Project 3 stuff is actually imported.
#
pyutilib.subprocess.run(
[sys.executable, currdir + os.sep + "egg2.py", currdir, "json"])
self.assertMatchesJsonBaseline(currdir + "egg2.out",
Expand All @@ -48,9 +56,5 @@ def test_egg2(self):
self.assertMatchesYamlBaseline(currdir + "egg2.out",
currdir + "egg2.yml")

# Apply class decorator explicitly, which works in Python 2.5
Test = unittest.skipIf(not pkg_resources_avail,
"Cannot import 'pkg_resources'")(Test)

if __name__ == "__main__":
unittest.main()
14 changes: 7 additions & 7 deletions pyutilib/misc/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ def test_parseDisplayAndValue_default(self):
self.skipTest("Cannot execute test because PyYAML is not available")
test = _display(self.config)
sys.stdout.write(test)
self.assertEqual(yaml.load(test), self.config.value())
self.assertEqual(yaml.load(test, Loader=yaml.FullLoader), self.config.value())

def test_parseDisplayAndValue_list(self):
if not using_yaml:
Expand All @@ -537,22 +537,22 @@ def test_parseDisplayAndValue_list(self):
self.config['scenarios'].append({'merlion': True, 'detection': []})
test = _display(self.config)
sys.stdout.write(test)
self.assertEqual(yaml.load(test), self.config.value())
self.assertEqual(yaml.load(test, Loader=yaml.FullLoader), self.config.value())

def test_parseDisplay_userdata_default(self):
if not using_yaml:
self.skipTest("Cannot execute test because PyYAML is not available")
test = _display(self.config, 'userdata')
sys.stdout.write(test)
self.assertEqual(yaml.load(test), None)
self.assertEqual(yaml.load(test, Loader=yaml.FullLoader), None)

def test_parseDisplay_userdata_list(self):
if not using_yaml:
self.skipTest("Cannot execute test because PyYAML is not available")
self.config['scenarios'].append()
test = _display(self.config, 'userdata')
sys.stdout.write(test)
self.assertEqual(yaml.load(test), {'scenarios': [None]})
self.assertEqual(yaml.load(test, Loader=yaml.FullLoader), {'scenarios': [None]})

def test_parseDisplay_userdata_list_nonDefault(self):
if not using_yaml:
Expand All @@ -562,7 +562,7 @@ def test_parseDisplay_userdata_list_nonDefault(self):
test = _display(self.config,'userdata')
sys.stdout.write(test)
self.assertEqual(
yaml.load(test), {'scenarios':
yaml.load(test, Loader=yaml.FullLoader), {'scenarios':
[None, {'merlion': True,
'detection': []}]})

Expand All @@ -573,7 +573,7 @@ def test_parseDisplay_userdata_block(self):
self.config.add("bar", ConfigBlock())
test = _display(self.config, 'userdata')
sys.stdout.write(test)
self.assertEqual(yaml.load(test), None)
self.assertEqual(yaml.load(test, Loader=yaml.FullLoader), None)

def test_parseDisplay_userdata_block_nonDefault(self):
if not using_yaml:
Expand All @@ -583,7 +583,7 @@ def test_parseDisplay_userdata_block_nonDefault(self):
.add("baz", ConfigBlock())
test = _display(self.config, 'userdata')
sys.stdout.write(test)
self.assertEqual(yaml.load(test), {'bar': None})
self.assertEqual(yaml.load(test, Loader=yaml.FullLoader), {'bar': None})

def test_value_ConfigValue(self):
val = self.config['flushing']['flush nodes']['rate']
Expand Down
3 changes: 3 additions & 0 deletions pyutilib/subprocess/processmngr.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def kill_process(process, sig=signal.SIGTERM, verbose=False):
print(" ERROR: invalid pid %d" % pid)
sys.exit(1)
os.killpg(pgid, signal.SIGTERM)
process.terminate()
#
# This is a hack. The Popen.__del__ method references
# the 'os' package, and when a process is interupted this
Expand Down Expand Up @@ -893,6 +894,8 @@ def kill(self, sig=signal.SIGTERM):
Kill the subprocess and its children
"""
kill_process(self.process, sig)
self.process.terminate()
self.process.wait()
del self.process
self.process = None

Expand Down
20 changes: 10 additions & 10 deletions pyutilib/subprocess/tests/test_subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ def test_timeout(self):
if ' ' in sys.executable:
foo = SubprocessMngr(
"'" + sys.executable + "' -q -c \"while True: pass\"",
shell=not _mswindows)
shell=False)
else:
foo = SubprocessMngr(
sys.executable + " -q -c \"while True: pass\"",
shell=not _mswindows)
shell=False)
foo.wait(targetTime)
runTime = timer() - stime
print("Ran for %f seconds" % (runTime,))
Expand Down Expand Up @@ -114,7 +114,7 @@ def test_outputfile(self):
INPUT.close()
os.remove(currdir + 'tee.out')
if _peek_available:
self.assertEquals(
self.assertEqual(
sorted(output.splitlines()),
["Tee Script: ERR", "Tee Script: OUT"])
else:
Expand All @@ -129,7 +129,7 @@ def test_ostream_stringio(self):
[sys.executable, currdir + "tee_script.py"], ostream=script_out)

if _peek_available:
self.assertEquals(
self.assertEqual(
sorted(script_out.getvalue().splitlines()),
["Tee Script: ERR", "Tee Script: OUT"])
else:
Expand All @@ -151,10 +151,10 @@ def test_tee(self):
pyutilib.misc.reset_redirect()
# The following is only deterministic if Peek/Select is available
if _peek_available:
self.assertEquals(
self.assertEqual(
sorted(stream_out.getvalue().splitlines()),
["Tee Script: ERR", "Tee Script: OUT"])
self.assertEquals(
self.assertEqual(
sorted(script_out.getvalue().splitlines()),
["Tee Script: ERR", "Tee Script: OUT"])
else:
Expand All @@ -179,12 +179,12 @@ def test_tee_stdout(self):
ostream=script_out,
tee=(True, False))
pyutilib.misc.reset_redirect()
self.assertEquals(stream_out.getvalue().splitlines(),
self.assertEqual(stream_out.getvalue().splitlines(),
["Tee Script: OUT"])

# The following is only deterministic if Peek/Select is available
if _peek_available:
self.assertEquals(
self.assertEqual(
sorted(script_out.getvalue().splitlines()),
["Tee Script: ERR", "Tee Script: OUT"])
else:
Expand All @@ -204,12 +204,12 @@ def test_tee_stderr(self):
ostream=script_out,
tee=(False, True))
pyutilib.misc.reset_redirect()
self.assertEquals(stream_out.getvalue().splitlines(),
self.assertEqual(stream_out.getvalue().splitlines(),
["Tee Script: ERR"])

# The following is only deterministic if Peek/Select is available
if _peek_available:
self.assertEquals(
self.assertEqual(
sorted(script_out.getvalue().splitlines()),
["Tee Script: ERR", "Tee Script: OUT"])
else:
Expand Down

0 comments on commit d02e0f6

Please sign in to comment.