def test_github_pull_request(): eq_({'github': {'owner': 'danvk', 'repo': 'dygraphs', 'num': 292}}, argparser.parse(['https://github.com/danvk/dygraphs/pull/292'])) eq_({'github': {'owner': 'danvk', 'repo': 'dygraphs', 'num': 292}}, argparser.parse(['https://github.com/danvk/dygraphs/pull/292/'])) eq_({'github': {'owner': 'danvk', 'repo': 'dygraphs', 'num': 292}}, argparser.parse(['https://github.com/danvk/dygraphs/pull/292/files'])) eq_({'github': {'owner': 'danvk', 'repo': 'dygraphs', 'num': 292}}, argparser.parse(['https://github.com/danvk/dygraphs/pull/292/commits']))
def run(): global DIFF, PORT, HOSTNAME try: parsed_args = argparser.parse(sys.argv[1:], VERSION) except argparser.UsageError as e: sys.stderr.write('Error: %s\n\n' % e.message) usage_and_die() DIFF = argparser.diff_for_args(parsed_args) if app.config['TESTING'] or app.config['DEBUG']: sys.stderr.write('Diff:\n%s' % DIFF) PORT = pick_a_port(parsed_args) if app.config.get('USE_HOSTNAME'): _hostname = platform.node() # platform.node will return empty string if it can't find the hostname if not _hostname: sys.stderr.write('Warning: hostname could not be determined') else: HOSTNAME = _hostname sys.stderr.write('''Serving diffs on http://%s:%s Close the browser tab or hit Ctrl-C when you're done. ''' % (HOSTNAME, PORT)) Timer(0.1, open_browser).start() app.run(host=HOSTNAME, port=PORT)
def test_file_dir_pairs(): eq_({'files': (file1, file2)}, argparser.parse([file1, file2])) eq_({'dirs': (dir1, dir2)}, argparser.parse([dir1, dir2])) with assert_raises(argparser.UsageError): argparser.parse([file1, dir1]) with assert_raises(argparser.UsageError): argparser.parse([dir2, file2])
def test_port(): eq_({'files': (file1, file2), 'port': 12345}, argparser.parse(['--port', '12345', file1, file2]))