def testArgPassing(self): expected = os.path.join('part1', 'part2', 'part3') with self.assertOutputMatches('%s\n' % expected): __main__.main( ['__main__.py', 'os.path', 'join', 'part1', 'part2', 'part3']) with self.assertOutputMatches('%s\n' % expected): __main__.main( ['__main__.py', 'os', 'path', '-', 'join', 'part1', 'part2', 'part3'])
def testArgPassing(self): expected = os.path.join("part1", "part2", "part3") with self.assertOutputMatches("%s\n" % expected): __main__.main( ["__main__.py", "os.path", "join", "part1", "part2", "part3"]) with self.assertOutputMatches("%s\n" % expected): __main__.main([ "__main__.py", "os", "path", "-", "join", "part1", "part2", "part3" ])
def testFileNameModuleDuplication(self): # Confirm that a file that masks a module still loads the module. with self.assertOutputMatches('gettempdir'): dirname = os.path.dirname(self.file.name) with testutils.ChangeDirectory(dirname): with open('tempfile', 'w'): __main__.main([ '__main__.py', 'tempfile', ]) os.remove('tempfile')
def testFileNameModuleFileFailure(self): # Confirm that an invalid file that masks a non-existent module fails. with self.assertRaisesRegex(ValueError, r'Fire can only be called on \.py files\.'): # pylint: disable=line-too-long, # pytype: disable=attribute-error dirname = os.path.dirname(self.file.name) with testutils.ChangeDirectory(dirname): with open('foobar', 'w'): __main__.main([ '__main__.py', 'foobar', ]) os.remove('foobar')
def testFileNameFailure(self): # Confirm that an existing file without a .py suffix raises a ValueError. with self.assertRaises(ValueError): __main__.main( ['__main__.py', self.file2.name, 'Foo', 'double', '--n', '2'])
def testFileNameFire(self): # Confirm that the file is correctly imported and doubles the number. with self.assertOutputMatches('4'): __main__.main( ['__main__.py', self.file.name, 'Foo', 'double', '--n', '2'])
def testNameSetting(self): # Confirm one of the usage lines has the gettempdir member. with self.assertOutputMatches('gettempdir'): __main__.main(['__main__.py', 'tempfile'])
def testFileNameFailure(self): # Confirm that an existing file without a .py suffix raises a ValueError. with self.assertRaises(ValueError): __main__.main( ["__main__.py", self.file2.name, "Foo", "double", "--n", "2"])
def testFileNameFire(self): # Confirm that the file is correctly imported and doubles the number. with self.assertOutputMatches("4"): __main__.main( ["__main__.py", self.file.name, "Foo", "double", "--n", "2"])
def testNameSetting(self): # Confirm one of the usage lines has the gettempdir member. with self.assertOutputMatches("gettempdir"): __main__.main(["__main__.py", "tempfile"])