Skip to content

Commit

Permalink
rhsplit: Fix tests to check error messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
slackner committed Aug 26, 2020
1 parent 8b9075c commit d5b0f37
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@

class RHSplitTests(unittest.TestCase):
def test_missing_path(self):
with self.assertRaises(subprocess.CalledProcessError):
output = subprocess.check_output(COMMAND, stderr=subprocess.STDOUT)
self.assertIn("Usage:", output)
with self.assertRaises(subprocess.CalledProcessError) as cm:
subprocess.check_output(COMMAND, stderr=subprocess.STDOUT)
self.assertIn(b"Usage:", cm.exception.output)

with self.assertRaises(subprocess.CalledProcessError):
output = subprocess.check_output(COMMAND + ["-z"], stderr=subprocess.STDOUT)
self.assertIn("Usage:", output)
with self.assertRaises(subprocess.CalledProcessError) as cm:
subprocess.check_output(COMMAND + ["-z"], stderr=subprocess.STDOUT)
self.assertIn(b"Usage:", cm.exception.output)

with self.assertRaises(subprocess.CalledProcessError):
output = subprocess.check_output(COMMAND + ["-Z"], stderr=subprocess.STDOUT)
self.assertIn("Usage:", output)
with self.assertRaises(subprocess.CalledProcessError) as cm:
subprocess.check_output(COMMAND + ["-Z"], stderr=subprocess.STDOUT)
self.assertIn(b"Usage:", cm.exception.output)

with self.assertRaises(subprocess.CalledProcessError):
output = subprocess.check_output(COMMAND + ["-h"], stderr=subprocess.STDOUT)
self.assertIn("Usage:", output)
with self.assertRaises(subprocess.CalledProcessError) as cm:
subprocess.check_output(COMMAND + ["-h"], stderr=subprocess.STDOUT)
self.assertIn(b"Usage:", cm.exception.output)

with self.assertRaises(subprocess.CalledProcessError):
output = subprocess.check_output(COMMAND + ["--"], stderr=subprocess.STDOUT)
self.assertIn("Usage:", output)
with self.assertRaises(subprocess.CalledProcessError) as cm:
subprocess.check_output(COMMAND + ["--"], stderr=subprocess.STDOUT)
self.assertIn(b"Usage:", cm.exception.output)

with self.assertRaises(subprocess.CalledProcessError):
output = subprocess.check_output(
with self.assertRaises(subprocess.CalledProcessError) as cm:
subprocess.check_output(
COMMAND + ["dir1", "dir2"], stderr=subprocess.STDOUT
)
self.assertIn("Usage:", output)
self.assertIn(b"Usage:", cm.exception.output)

def test_nonexistent(self):
with tempfile.TemporaryDirectory() as temp_path:
Expand Down

0 comments on commit d5b0f37

Please sign in to comment.