always parse args from sys.argv
This commit is contained in:
parent
271e457654
commit
f818a64d3d
5 changed files with 26 additions and 32 deletions
|
@ -1,10 +1,10 @@
|
|||
usage: nosetests [-h] --file file [--key KEY] [--write] [--plugin PLUGIN]
|
||||
[--time time] [--lineno LINENO] [--cursorpos CURSORPOS]
|
||||
[--notfile] [--proxy PROXY] [--project PROJECT]
|
||||
[--alternate-project ALTERNATE_PROJECT] [--hostname HOSTNAME]
|
||||
[--disableoffline] [--hidefilenames] [--exclude EXCLUDE]
|
||||
[--include INCLUDE] [--logfile LOGFILE] [--apiurl API_URL]
|
||||
[--config CONFIG] [--verbose] [--version]
|
||||
usage: wakatime [-h] --file file [--key KEY] [--write] [--plugin PLUGIN]
|
||||
[--time time] [--lineno LINENO] [--cursorpos CURSORPOS]
|
||||
[--notfile] [--proxy PROXY] [--project PROJECT]
|
||||
[--alternate-project ALTERNATE_PROJECT] [--hostname HOSTNAME]
|
||||
[--disableoffline] [--hidefilenames] [--exclude EXCLUDE]
|
||||
[--include INCLUDE] [--logfile LOGFILE] [--apiurl API_URL]
|
||||
[--config CONFIG] [--verbose] [--version]
|
||||
|
||||
Common interface for the WakaTime api.
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
usage: nosetests [-h] --file file [--key KEY] [--write] [--plugin PLUGIN]
|
||||
[--time time] [--lineno LINENO] [--cursorpos CURSORPOS]
|
||||
[--notfile] [--proxy PROXY] [--project PROJECT]
|
||||
[--alternate-project ALTERNATE_PROJECT] [--hostname HOSTNAME]
|
||||
[--disableoffline] [--hidefilenames] [--exclude EXCLUDE]
|
||||
[--include INCLUDE] [--logfile LOGFILE] [--apiurl API_URL]
|
||||
[--config CONFIG] [--verbose] [--version]
|
||||
nosetests: error: Missing api key
|
||||
usage: wakatime [-h] --file file [--key KEY] [--write] [--plugin PLUGIN]
|
||||
[--time time] [--lineno LINENO] [--cursorpos CURSORPOS]
|
||||
[--notfile] [--proxy PROXY] [--project PROJECT]
|
||||
[--alternate-project ALTERNATE_PROJECT] [--hostname HOSTNAME]
|
||||
[--disableoffline] [--hidefilenames] [--exclude EXCLUDE]
|
||||
[--include INCLUDE] [--logfile LOGFILE] [--apiurl API_URL]
|
||||
[--config CONFIG] [--verbose] [--version]
|
||||
wakatime: error: Missing api key
|
||||
|
|
|
@ -18,7 +18,7 @@ from wakatime.base import main
|
|||
class BaseTestCase(utils.TestCase):
|
||||
|
||||
def test_help_contents(self, mock_requests):
|
||||
args = ['', '--help']
|
||||
args = ['--help']
|
||||
with self.assertRaises(SystemExit):
|
||||
main(args)
|
||||
expected_stdout = open('tests/samples/output/test_help_contents').read()
|
||||
|
@ -29,7 +29,7 @@ class BaseTestCase(utils.TestCase):
|
|||
response = Response()
|
||||
response.status_code = 201
|
||||
mock_requests.return_value = response
|
||||
args = ['', '--file', 'tests/samples/emptyfile.txt', '--key', '123', '--config', 'foo']
|
||||
args = ['--file', 'tests/samples/emptyfile.txt', '--key', '123', '--config', 'foo']
|
||||
retval = main(args)
|
||||
self.assertEquals(retval, 0)
|
||||
expected_stdout = u("Error: Could not read from config file foo\n")
|
||||
|
@ -37,7 +37,7 @@ class BaseTestCase(utils.TestCase):
|
|||
self.assertEquals(sys.stderr.getvalue(), '')
|
||||
|
||||
def test_missing_config_file(self, mock_requests):
|
||||
args = ['', '--file', 'tests/samples/emptyfile.txt', '--config', 'foo']
|
||||
args = ['--file', 'tests/samples/emptyfile.txt', '--config', 'foo']
|
||||
with self.assertRaises(SystemExit):
|
||||
main(args)
|
||||
expected_stdout = u("Error: Could not read from config file foo\n")
|
||||
|
@ -49,14 +49,14 @@ class BaseTestCase(utils.TestCase):
|
|||
response = Response()
|
||||
response.status_code = 201
|
||||
mock_requests.return_value = response
|
||||
args = ['', '--file', 'tests/samples/emptyfile.txt', '--config', 'tests/samples/sample.cfg']
|
||||
args = ['--file', 'tests/samples/emptyfile.txt', '--config', 'tests/samples/sample.cfg']
|
||||
retval = main(args)
|
||||
self.assertEquals(retval, 0)
|
||||
self.assertEquals(sys.stdout.getvalue(), '')
|
||||
self.assertEquals(sys.stderr.getvalue(), '')
|
||||
|
||||
def test_parse_bad_config_file(self, mock_requests):
|
||||
args = ['', '--file', 'tests/samples/emptyfile.txt', '--config', 'tests/samples/bad_config.cfg']
|
||||
args = ['--file', 'tests/samples/emptyfile.txt', '--config', 'tests/samples/bad_config.cfg']
|
||||
retval = main(args)
|
||||
self.assertEquals(retval, 103)
|
||||
self.assertIn('ParsingError', sys.stdout.getvalue())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue