def test_format_path(): formatter = Formatter() file_contents = dict(get_contents('tests/samples/')) formatter.format_path('tests/samples/', recursive=True) for k, v in get_contents('tests/samples/'): check_or_revert(file_contents, k, v) formatter.format_path('tests/samples/generators.py')
def test_string(): tools.eq_( Formatter.format_string('''a = 'b' '''), '''a = 'b'\n\n''', ) formatter = Formatter() formatter.format_path('tests/samples/continuations.py')
def test_stdin(): fh = StringIO() formatter = Formatter() sys.stdin, stdin = fh, sys.stdin print(u'test = 123', file=fh) fh.seek(0) formatter('-'), fh.seek(0) formatter.format_file('-'), fh.seek(0) formatter(sys.stdin), filename = 'tests/test_brace.py' test_brace_contents = open(filename, 'r').read() formatter(filename) assert test_brace_contents == open(filename, 'r').read() sys.stdin = stdin