-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
user assertTrue instead of assertIn, py26 doesn't have assertIn
- Loading branch information
Showing
2 changed files
with
71 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -206,14 +206,14 @@ def test_runforever_eager_error_on_request_some(self): | |
prog.stdin.seek(0) | ||
prog.runforever(test=True) | ||
lines = prog.stderr.getvalue().split('\n') | ||
self.assertIn("Restarting selected processes ['foo', 'bar', " | ||
"'baz_01', 'notexisting']", lines[0]) | ||
self.assertIn('foo is in RUNNING state, restarting', lines[1]) | ||
self.assertIn('foo restarted', lines[2]) | ||
self.assertIn('bar not in RUNNING state, NOT restarting', lines[3]) | ||
self.assertIn('baz:baz_01 not in RUNNING state, NOT restarting', | ||
self.assertTrue("Restarting selected processes ['foo', 'bar', " | ||
"'baz_01', 'notexisting']" in lines[0]) | ||
self.assertTrue('foo is in RUNNING state, restarting' in lines[1]) | ||
self.assertTrue('foo restarted' in lines[2]) | ||
self.assertTrue('bar not in RUNNING state, NOT restarting' in lines[3]) | ||
self.assertTrue('baz:baz_01 not in RUNNING state, NOT restarting' in | ||
lines[4]) | ||
self.assertIn("Programs not restarted because " | ||
self.assertTrue("Programs not restarted because " | ||
"they did not exist: ['notexisting']", lines[5]) | ||
mailed = prog.mailed.split('\n') | ||
self.assertEqual(len(mailed), 12) | ||
|
@@ -229,11 +229,11 @@ def test_runforever_eager_error_on_request_any(self): | |
prog.stdin.seek(0) | ||
prog.runforever(test=True) | ||
lines = prog.stderr.getvalue().split('\n') | ||
self.assertIn('Restarting all running processes', lines[0]) | ||
self.assertIn('foo is in RUNNING state, restarting', lines[1]) | ||
self.assertIn('foo restarted', lines[2]) | ||
self.assertIn('bar not in RUNNING state, NOT restarting', lines[3]) | ||
self.assertIn('baz:baz_01 not in RUNNING state, NOT restarting', | ||
self.assertTrue('Restarting all running processes' in lines[0]) | ||
self.assertTrue('foo is in RUNNING state, restarting' in lines[1]) | ||
self.assertTrue('foo restarted' in lines[2]) | ||
self.assertTrue('bar not in RUNNING state, NOT restarting' in lines[3]) | ||
self.assertTrue('baz:baz_01 not in RUNNING state, NOT restarting' in | ||
lines[4]) | ||
mailed = prog.mailed.split('\n') | ||
self.assertEqual(len(mailed), 11) | ||
|
@@ -250,11 +250,11 @@ def test_runforever_eager_error_on_process_stop(self): | |
prog.stdin.seek(0) | ||
prog.runforever(test=True) | ||
lines = prog.stderr.getvalue().split('\n') | ||
self.assertIn("Restarting selected processes ['FAILED']", lines[0]) | ||
self.assertIn('foo:FAILED is in RUNNING state, restarting', lines[1]) | ||
self.assertIn("Failed to stop process foo:FAILED: " | ||
"<Fault 30: 'FAILED'>", lines[2]) | ||
self.assertIn('foo:FAILED restarted', lines[3]) | ||
self.assertTrue("Restarting selected processes ['FAILED']" in lines[0]) | ||
self.assertTrue('foo:FAILED is in RUNNING state, restarting' in lines[1]) | ||
self.assertTrue("Failed to stop process foo:FAILED: " | ||
"<Fault 30: 'FAILED'>" in lines[2]) | ||
self.assertTrue('foo:FAILED restarted' in lines[3]) | ||
mailed = prog.mailed.split('\n') | ||
self.assertEqual(len(mailed), 10) | ||
self.assertEqual(mailed[0], 'To: [email protected]') | ||
|
@@ -270,11 +270,11 @@ def test_runforever_eager_error_on_process_start(self): | |
prog.stdin.seek(0) | ||
prog.runforever(test=True) | ||
lines = prog.stderr.getvalue().split('\n') | ||
self.assertIn("Restarting selected processes ['SPAWN_ERROR']", lines[0]) | ||
self.assertIn('foo:SPAWN_ERROR is in RUNNING state, restarting', | ||
self.assertTrue("Restarting selected processes ['SPAWN_ERROR']" in lines[0]) | ||
self.assertTrue('foo:SPAWN_ERROR is in RUNNING state, restarting' in | ||
lines[1]) | ||
self.assertIn("Failed to start process foo:SPAWN_ERROR: " | ||
"<Fault 50: 'SPAWN_ERROR'>", lines[2]) | ||
self.assertTrue("Failed to start process foo:SPAWN_ERROR: " | ||
"<Fault 50: 'SPAWN_ERROR'>" in lines[2]) | ||
mailed = prog.mailed.split('\n') | ||
self.assertEqual(len(mailed), 9) | ||
self.assertEqual(mailed[0], 'To: [email protected]') | ||
|
@@ -290,18 +290,18 @@ def test_runforever_eager_gcore(self): | |
prog.stdin.seek(0) | ||
prog.runforever(test=True) | ||
lines = prog.stderr.getvalue().split('\n') | ||
self.assertIn("Restarting selected processes ['foo', 'bar', " | ||
"'baz_01', 'notexisting']", lines[0]) | ||
self.assertIn('gcore output for foo:', lines[1]) | ||
self.assertTrue("Restarting selected processes ['foo', 'bar', " | ||
"'baz_01', 'notexisting']" in lines[0]) | ||
self.assertTrue('gcore output for foo:' in lines[1]) | ||
self.assertEqual(lines[2], '') | ||
self.assertEqual(lines[3], ' ') | ||
self.assertIn('foo is in RUNNING state, restarting', lines[4]) | ||
self.assertIn('foo restarted', lines[5]) | ||
self.assertIn('bar not in RUNNING state, NOT restarting', lines[6]) | ||
self.assertIn('baz:baz_01 not in RUNNING state, NOT restarting', | ||
self.assertTrue('foo is in RUNNING state, restarting' in lines[4]) | ||
self.assertTrue('foo restarted' in lines[5]) | ||
self.assertTrue('bar not in RUNNING state, NOT restarting' in lines[6]) | ||
self.assertTrue('baz:baz_01 not in RUNNING state, NOT restarting' in | ||
lines[7]) | ||
self.assertIn("Programs not restarted because they did not exist: " | ||
"['notexisting']", lines[8]) | ||
self.assertTrue("Programs not restarted because they did not exist: " | ||
"['notexisting']" in lines[8]) | ||
mailed = prog.mailed.split('\n') | ||
self.assertEqual(len(mailed), 15) | ||
self.assertEqual(mailed[0], 'To: [email protected]') | ||
|
@@ -328,10 +328,10 @@ def test_runforever_not_eager_running(self): | |
prog.stdin.seek(0) | ||
prog.runforever(test=True) | ||
lines = [x for x in prog.stderr.getvalue().split('\n') if x] | ||
self.assertIn("Restarting selected processes ['foo', 'bar']", lines[0]) | ||
self.assertIn('foo is in RUNNING state, restarting', lines[1]) | ||
self.assertIn('foo restarted', lines[2]) | ||
self.assertIn('bar not in RUNNING state, NOT restarting', lines[3]) | ||
self.assertTrue("Restarting selected processes ['foo', 'bar']" in lines[0]) | ||
self.assertTrue('foo is in RUNNING state, restarting' in lines[1]) | ||
self.assertTrue('foo restarted' in lines[2]) | ||
self.assertTrue('bar not in RUNNING state, NOT restarting' in lines[3]) | ||
mailed = prog.mailed.split('\n') | ||
self.assertEqual(len(mailed), 10) | ||
self.assertEqual(mailed[0], 'To: [email protected]') | ||
|
@@ -361,10 +361,11 @@ def test_runforever_connrefused_error(self): | |
prog.stdin.seek(0) | ||
prog.runforever(test=True) | ||
lines = [x for x in prog.stderr.getvalue().split('\n') if x] | ||
self.assertIn("Restarting selected processes ['foo', 'bar']", lines[0]) | ||
self.assertIn('foo is in RUNNING state, restarting', lines[1]) | ||
self.assertIn('foo restarted', lines[2]) | ||
self.assertIn('bar not in RUNNING state, NOT restarting', lines[3]) | ||
self.assertTrue("Restarting selected processes ['foo', 'bar']" | ||
in lines[0]) | ||
self.assertTrue('foo is in RUNNING state, restarting' in lines[1]) | ||
self.assertTrue('foo restarted' in lines[2]) | ||
self.assertTrue('bar not in RUNNING state, NOT restarting' in lines[3]) | ||
mailed = prog.mailed.split('\n') | ||
self.assertEqual(len(mailed), 10) | ||
self.assertEqual(mailed[0], 'To: [email protected]') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,13 +54,13 @@ def test_runforever_tick_programs(self): | |
memmon.runforever(test=True) | ||
lines = memmon.stderr.getvalue().split('\n') | ||
self.assertEqual(len(lines), 8) | ||
self.assertIn('Checking programs bar=0, baz_01=0, foo=0', lines[0]) | ||
self.assertIn('RSS of foo:foo is 2264064', lines[1]) | ||
self.assertIn('Restarting foo:foo', lines[2]) | ||
self.assertIn('RSS of bar:bar is 2265088', lines[3]) | ||
self.assertIn('Restarting bar:bar', lines[4]) | ||
self.assertIn('RSS of baz:baz_01 is 2265088', lines[5]) | ||
self.assertIn('Restarting baz:baz_01', lines[6]) | ||
self.assertTrue('Checking programs bar=0, baz_01=0, foo=0' in lines[0]) | ||
self.assertTrue('RSS of foo:foo is 2264064' in lines[1]) | ||
self.assertTrue('Restarting foo:foo' in lines[2]) | ||
self.assertTrue('RSS of bar:bar is 2265088' in lines[3]) | ||
self.assertTrue('Restarting bar:bar' in lines[4]) | ||
self.assertTrue('RSS of baz:baz_01 is 2265088' in lines[5]) | ||
self.assertTrue('Restarting baz:baz_01' in lines[6]) | ||
self.assertEqual(lines[7], '') | ||
mailed = memmon.mailed.split('\n') | ||
self.assertEqual(len(mailed), 4) | ||
|
@@ -80,9 +80,9 @@ def test_runforever_tick_groups(self): | |
memmon.runforever(test=True) | ||
lines = memmon.stderr.getvalue().split('\n') | ||
self.assertEqual(len(lines), 4) | ||
self.assertIn('Checking groups foo=0', lines[0]) | ||
self.assertIn('RSS of foo:foo is 2264064', lines[1]) | ||
self.assertIn('Restarting foo:foo', lines[2]) | ||
self.assertTrue('Checking groups foo=0' in lines[0]) | ||
self.assertTrue('RSS of foo:foo is 2264064' in lines[1]) | ||
self.assertTrue('Restarting foo:foo' in lines[2]) | ||
self.assertEqual(lines[3], '') | ||
mailed = memmon.mailed.split('\n') | ||
self.assertEqual(len(mailed), 4) | ||
|
@@ -102,13 +102,13 @@ def test_runforever_tick_any(self): | |
memmon.runforever(test=True) | ||
lines = memmon.stderr.getvalue().split('\n') | ||
self.assertEqual(len(lines), 8) | ||
self.assertIn('Checking any=0', lines[0]) | ||
self.assertIn('RSS of foo:foo is 2264064', lines[1]) | ||
self.assertIn('Restarting foo:foo', lines[2]) | ||
self.assertIn('RSS of bar:bar is 2265088', lines[3]) | ||
self.assertIn('Restarting bar:bar', lines[4]) | ||
self.assertIn('RSS of baz:baz_01 is 2265088', lines[5]) | ||
self.assertIn('Restarting baz:baz_01', lines[6]) | ||
self.assertTrue('Checking any=0' in lines[0]) | ||
self.assertTrue('RSS of foo:foo is 2264064' in lines[1]) | ||
self.assertTrue('Restarting foo:foo' in lines[2]) | ||
self.assertTrue('RSS of bar:bar is 2265088' in lines[3]) | ||
self.assertTrue('Restarting bar:bar' in lines[4]) | ||
self.assertTrue('RSS of baz:baz_01 is 2265088' in lines[5]) | ||
self.assertTrue('Restarting baz:baz_01' in lines[6]) | ||
self.assertEqual(lines[7], '') | ||
mailed = memmon.mailed.split('\n') | ||
self.assertEqual(len(mailed), 4) | ||
|
@@ -123,12 +123,12 @@ def test_runforever_tick_programs_and_groups(self): | |
memmon.runforever(test=True) | ||
lines = memmon.stderr.getvalue().split('\n') | ||
self.assertEqual(len(lines), 7) | ||
self.assertIn('Checking programs baz_01=0', lines[0]) | ||
self.assertIn('Checking groups foo=0', lines[1]) | ||
self.assertIn('RSS of foo:foo is 2264064', lines[2]) | ||
self.assertIn('Restarting foo:foo', lines[3]) | ||
self.assertIn('RSS of baz:baz_01 is 2265088', lines[4]) | ||
self.assertIn('Restarting baz:baz_01', lines[5]) | ||
self.assertTrue('Checking programs baz_01=0' in lines[0]) | ||
self.assertTrue('Checking groups foo=0' in lines[1]) | ||
self.assertTrue('RSS of foo:foo is 2264064' in lines[2]) | ||
self.assertTrue('Restarting foo:foo' in lines[3]) | ||
self.assertTrue('RSS of baz:baz_01 is 2265088' in lines[4]) | ||
self.assertTrue('Restarting baz:baz_01' in lines[5]) | ||
self.assertEqual(lines[6], '') | ||
mailed = memmon.mailed.split('\n') | ||
self.assertEqual(len(mailed), 4) | ||
|
@@ -148,8 +148,8 @@ def test_runforever_tick_programs_norestart(self): | |
memmon.runforever(test=True) | ||
lines = memmon.stderr.getvalue().split('\n') | ||
self.assertEqual(len(lines), 3) | ||
self.assertIn('Checking programs foo=%s' % maxint, lines[0]) | ||
self.assertIn('RSS of foo:foo is 2264064', lines[1]) | ||
self.assertTrue('Checking programs foo=%s' % maxint in lines[0]) | ||
self.assertTrue('RSS of foo:foo is 2264064' in lines[1]) | ||
self.assertEqual(lines[2], '') | ||
self.assertEqual(memmon.mailed, False) | ||
|
||
|
@@ -163,8 +163,8 @@ def test_stopprocess_fault_tick_programs_norestart(self): | |
memmon.runforever(test=True) | ||
lines = memmon.stderr.getvalue().split('\n') | ||
self.assertEqual(len(lines), 3) | ||
self.assertIn('Checking programs foo=%s' % maxint, lines[0]) | ||
self.assertIn('RSS of foo:foo is 2264064', lines[1]) | ||
self.assertTrue('Checking programs foo=%s' % maxint in lines[0]) | ||
self.assertTrue('RSS of foo:foo is 2264064' in lines[1]) | ||
self.assertEqual(lines[2], '') | ||
self.assertEqual(memmon.mailed, False) | ||
|
||
|
@@ -192,17 +192,17 @@ def test_stopprocess_fails_to_stop(self): | |
self.assertRaises(xmlrpclib.Fault, memmon.runforever, True) | ||
lines = memmon.stderr.getvalue().split('\n') | ||
self.assertEqual(len(lines), 4) | ||
self.assertIn('Checking programs BAD_NAME=%s' % 0, lines[0]) | ||
self.assertIn('RSS of BAD_NAME:BAD_NAME is 2264064', lines[1]) | ||
self.assertIn('Restarting BAD_NAME:BAD_NAME', lines[2]) | ||
self.assertIn('Failed', lines[3]) | ||
self.assertTrue('Checking programs BAD_NAME=%s' % 0 in lines[0]) | ||
self.assertTrue('RSS of BAD_NAME:BAD_NAME is 2264064' in lines[1]) | ||
self.assertTrue('Restarting BAD_NAME:BAD_NAME' in lines[2]) | ||
self.assertTrue('Failed' in lines[3]) | ||
mailed = memmon.mailed.split('\n') | ||
self.assertEqual(len(mailed), 4) | ||
self.assertEqual(mailed[0], 'To: [email protected]') | ||
self.assertEqual(mailed[1], | ||
'Subject: memmon: failed to stop process BAD_NAME:BAD_NAME, exiting') | ||
self.assertEqual(mailed[2], '') | ||
self.assertIn('Failed', mailed[3]) | ||
self.assertTrue('Failed' in mailed[3]) | ||
|
||
def test_subject_no_name(self): | ||
"""set the name to None to check if subject formats to: | ||
|