def test_bscr_version_help(): """ Test 'bscr version -h' """ pytest.debug_func() cmd = "bscr version -h" result = th.rm_cov_warn(pexpect.run(cmd)) assert "Traceback" not in result assert "Usage: bscr [options]" in result assert "-d, --debug run under the debugger" in result
def test_named_input(self): """ Handle both input on stdin as well as input from a named file. """ tfilename = 'testdata' f = open(tfilename, 'w') for line in self.tdata: f.write(line + "\n") f.close() script = U.script_location("align") x = th.rm_cov_warn(pexpect.run("%s %s" % (script, tfilename))) self.assertEq(self.exp, x)
def test_bscr_version(self): """ Test 'bscr version' """ self.dbgfunc() cmd = "bscr version -v" result = th.rm_cov_warn(pexpect.run(cmd)) self.assertTrue("Traceback" not in result, "Not expecting 'Traceback' in %s" % U.lquote(result)) self.assertTrue("Backscratcher version" in result) self.assertEqual(2, len(result.split("\n")), "Expected only 1 newlines in %s" % U.lquote(result))
def test_digit_alignment(self): """ Words that contain valid numeric specifications should be right aligned. Words containing non-numeric values should be left aligned. """ script = U.script_location("align") S = pexpect.spawn(script) S.setecho(False) for line in self.tdata: S.sendline(line) S.send("\004") S.expect(pexpect.EOF) x = th.rm_cov_warn(S.before) S.close() self.assertEq(self.exp, x)
def test_0_pep8(self): """ Check the code in this package for PEP8 conformance. """ # pdb.set_trace() pep8 = pexpect.which('pep8') if pep8 is None: pytest.skip("Pep8 tool not found") else: root = U.bscr_root() for r, d, f in os.walk(root): pylist = [U.pj(r, x) for x in f if x.endswith(".py")] args = " ".join(pylist) if args != '': cmd = "pep8 %s" % args # print cmd result = th.rm_cov_warn(pexpect.run(cmd)) self.assertEqual('', result, "Pep8 report: %s" % result)