コード例 #1
0
ファイル: test_main.py プロジェクト: thoward27/grade
 def test_successful_no_output():
     Pipeline(
         Run([PYTHON, "-m", "grade", "run", "-p", "test_mixins.py"]),
         AssertExitSuccess(),
         AssertStdoutMatches(""),
         AssertStderrMatches(""),
     )()
コード例 #2
0
ファイル: test_asserts.py プロジェクト: thoward27/grade
 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")
コード例 #3
0
ファイル: test_asserts.py プロジェクト: thoward27/grade
 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")
コード例 #4
0
ファイル: test_asserts.py プロジェクト: thoward27/grade
 def test_passing_both(self):
     results = Run(">&2 echo hello", shell=True)()
     with self.assertRaises(ValueError):
         AssertStderrMatches("hello", "world")(results)
コード例 #5
0
ファイル: test_asserts.py プロジェクト: thoward27/grade
 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)
コード例 #6
0
ファイル: test_asserts.py プロジェクト: thoward27/grade
 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)
コード例 #7
0
ファイル: test_asserts.py プロジェクト: thoward27/grade
 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)
コード例 #8
0
ファイル: test_asserts.py プロジェクト: thoward27/grade
 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)