def testMissingPackage(self): """Test that running without a package argument exits with an error.""" with self.OutputCapturer(): # Running without a package should exit with code!=0 try: mps.main(['--out=any-out']) except exceptions.SystemExit, e: self.assertNotEquals(e.args[0], 0)
def testMissingOut(self): """Test that running without --out exits with an error.""" with self.OutputCapturer(): # Running without --out should exit with code!=0 try: mps.main([]) except exceptions.SystemExit, e: self.assertNotEquals(e.args[0], 0)
def testHelp(self): """Test that --help is functioning""" with self.OutputCapturer() as output: # Running with --help should exit with code==0 try: mps.main(['--help']) except exceptions.SystemExit, e: self.assertEquals(e.args[0], 0)
def testMain(self): """Verify that running main method runs expected functons. Expected: LoadAndMergeTables, WriteTable. """ self.PatchObject(mps, 'LoadAndMergeTables', return_value='csv_table') m = self.PatchObject(mps, 'WriteTable') mps.main(['--out=any-out', 'any-package']) m.assert_called_with('csv_table', os.path.join(os.getcwd(), 'any-out'))
def testMain(self): """Verify that running main method runs expected functons. Expected: LoadAndMergeTables, WriteTable. """ self.PatchObject(mps, "LoadAndMergeTables", return_value="csv_table") m = self.PatchObject(mps, "WriteTable") mps.main(["--out=any-out", "any-package"]) m.assert_called_with("csv_table", "any-out")
def testMissingPackage(self): """Test that running without a package argument exits with an error.""" with self.OutputCapturer(): # Running without a package should exit with code!=0 try: mps.main(["--out=any-out"]) except exceptions.SystemExit as e: self.assertNotEquals(e.args[0], 0) # Verify that output ends in error. self.AssertOutputEndsInError()
def testMissingPackage(self): """Test that running without a package argument exits with an error.""" with self.OutputCapturer() as output: # Running without a package should exit with code!=0 try: mps.main(['--out=any-out']) except exceptions.SystemExit as e: self.assertNotEquals(e.args[0], 0) # Verify that output ends in error. stderr = output.GetStderr() self.assertIn('error: too few arguments', stderr)
def testMissingOut(self): """Test that running without --out exits with an error.""" with self.OutputCapturer() as output: # Running without --out should exit with code!=0 try: mps.main(['pkg']) except exceptions.SystemExit as e: self.assertNotEquals(e.args[0], 0) # Verify that output ends in error. stderr = output.GetStderr() self.assertIn('error: argument --out is required', stderr)
def testMain(self): """Verify that running main method runs expected functons. Expected: LoadAndMergeTables, WriteTable. """ self.mox.StubOutWithMock(mps, 'LoadAndMergeTables') self.mox.StubOutWithMock(mps, 'WriteTable') mps.LoadAndMergeTables(mox.IgnoreArg()).AndReturn('csv_table') mps.WriteTable(mox.Regex(r'csv_table'), 'any-out') self.mox.ReplayAll() mps.main(['--out=any-out', 'any-package']) self.mox.VerifyAll()
def testMain(self): """Verify that running main method runs expected functons. Expected: LoadAndMergeTables, WriteTable. """ self.mox.StubOutWithMock(mps, "LoadAndMergeTables") self.mox.StubOutWithMock(mps, "WriteTable") mps.LoadAndMergeTables(mox.IgnoreArg()).AndReturn("csv_table") mps.WriteTable(mox.Regex(r"csv_table"), "any-out") self.mox.ReplayAll() mps.main(["--out=any-out", "any-package"]) self.mox.VerifyAll()
def testHelp(self): """Test that --help is functioning""" with self.OutputCapturer() as output: # Running with --help should exit with code==0 try: mps.main(['--help']) except SystemExit as e: self.assertEqual(e.args[0], 0) # Verify that a message beginning with "Usage: " was printed stdout = output.GetStdout() self.assertTrue(stdout.startswith('usage: '), msg='Expected output starting with "usage: " but got:\n%s' % stdout)
def testHelp(self): """Test that --help is functioning""" with self.OutputCapturer() as output: # Running with --help should exit with code==0 try: mps.main(["--help"]) except exceptions.SystemExit as e: self.assertEquals(e.args[0], 0) # Verify that a message beginning with "Usage: " was printed stdout = output.GetStdout() self.assertTrue( stdout.startswith("Usage: "), msg='Expected output starting with "Usage: " but got:\n%s' % stdout )
def testMissingPackage(self): """Test that running without a package argument exits with an error.""" with self.OutputCapturer() as output: # Running without a package should exit with code!=0 try: mps.main(['--out=any-out']) except SystemExit as e: self.assertNotEqual(e.args[0], 0) # Verify that output ends in error. stderr = output.GetStderr() # Python changed argparse output style. # TODO(vapier): Drop this once we require Python 3 everywhere. if sys.version_info.major < 3: self.assertIn('error: too few arguments', stderr) else: self.assertIn('error: the following arguments are required', stderr)