Exemplo n.º 1
0
 def test_successful_no_output():
     Pipeline(
         Run([PYTHON, "-m", "grade", "run", "-p", "test_mixins.py"]),
         AssertExitSuccess(),
         AssertStdoutMatches(""),
         AssertStderrMatches(""),
     )()
Exemplo n.º 2
0
 def test_inferring_filename(self):
     """ Can we infer filename if conventions are followed? """
     results = Run(["grep", "-h"])()
     results = WriteOutputs("-h")(results)
     results = AssertStderrMatches()(results)
     self.assertIsInstance(results, CompletedProcess)
     os.remove("-h.stdout")
     os.remove("-h.stderr")
Exemplo n.º 3
0
 def test_passing_filename():
     results = Run(">&2 echo hello", shell=True)()
     with open("hello.stderr", "w") as f:
         f.write("hello")
     AssertStderrMatches(filepath="hello.stderr")(results)
     os.remove("hello.stderr")
Exemplo n.º 4
0
 def test_passing_both(self):
     results = Run(">&2 echo hello", shell=True)()
     with self.assertRaises(ValueError):
         AssertStderrMatches("hello", "world")(results)
Exemplo n.º 5
0
 def test_cannot_infer_shell(self):
     """ Should not be able to infer filename when shell=True """
     results = Run(">&2 echo hello_world", shell=True)()
     with self.assertRaises(ValueError):
         AssertStderrMatches()(results)
Exemplo n.º 6
0
 def test_cannot_infer_filename(self):
     """ What if there is no file to infer from? """
     results = Run(["grep", "-h"])()
     with self.assertRaises(AssertionError):
         AssertStderrMatches()(results)
Exemplo n.º 7
0
 def test_stderr_matches(self):
     """ What if stderr does match? """
     results = Run(">&2 echo hello_world", shell=True)()
     results = AssertStderrMatches("hello_world")(results)
     self.assertIsInstance(results, CompletedProcess)
Exemplo n.º 8
0
 def test_stderr_no_match(self):
     """ What happens when stderr does not match? """
     results = Run(">&2 echo hello_world", shell=True)()
     with self.assertRaises(AssertionError):
         AssertStderrMatches("goodbye_world")(results)