def test_return_code(self): # 0: match found or help/version printed # 1: no match # 2: error sys.stdout = StringIO() # help is not printed through output_formatter sys.stderr = StringIO() # errors by optparse go here try: for args, expected in [(['--help'], 0), (['--version'], 0), ([], 0), # prints help (['abc', self.testdir1], 0), (['--py', 'abc', self.testdir1], 1), (['no match here', self.testdir1], 1), (['--invalid'], 2), ([['invalid arg causes error']], 2)]: rc = main(['pss'] + args, output_formatter=self.of) self.assertEquals(rc, expected) finally: sys.stdout = sys.__stdout__ sys.stderr = sys.__stderr__
def test_return_code(self): # 0: match found or help/version printed # 1: no match # 2: error sys.stdout = StringIO() # help is not printed through output_formatter sys.stderr = StringIO() # errors by optparse go here try: for args, expected in [ (['--help'], 0), (['--version'], 0), ([], 0), # prints help (['abc', self.testdir1], 0), (['--py', 'abc', self.testdir1], 1), (['no match here', self.testdir1], 1), (['--invalid'], 2), ([['invalid arg causes error']], 2) ]: rc = main(['pss'] + args, output_formatter=self.of) self.assertEquals(rc, expected) finally: sys.stdout = sys.__stdout__ sys.stderr = sys.__stderr__
def cherche(mot): # exclude all strings of keys pss.main(['']+['.*?:.*?'+mot, "--json", "/data/audio/"], output_formatter=of) return of.output
def _run_main(self, args, dir=None, output_formatter=None, expected_rc=0): rc = main(argv=[''] + args + [dir or self.testdir1], output_formatter=output_formatter or self.of) self.assertEqual(rc, expected_rc)
def _run_main(self, args, dir=None, output_formatter=None, expected_rc=0): rc = main( argv=[''] + args + [dir or self.testdir1], output_formatter=output_formatter or self.of) self.assertEquals(rc, expected_rc)
#!/usr/bin/env python # Used for direct invocation of this directory by python, without actually # having to install pss from psslib.pss import main; main()
def _run_main(self, args, dir=None, output_formatter=None): main( argv=[''] + args + [dir or self.testdir1], output_formatter=output_formatter or self.of)
#!/usr/bin/env python import sys from psslib.pss import main sys.exit(main())
#!/usr/bin/env python from psslib.pss import main; main()
def _run_main(self, args, dir=None, output_formatter=None): main(argv=[''] + args + [dir or self.testdir1], output_formatter=output_formatter or self.of)