myint / pyformat

Formats Python code to follow a consistent style
https://pypi.python.org/pypi/pyformat
96 stars 10 forks source link

added test for --no-config option #4

Closed generalov closed 8 years ago

myint commented 8 years ago

I would prefer not changing directories. I think this may fail if the tests are run in parallel. Is there any reason for changing directories?

generalov commented 8 years ago

Because the autopep8 searches a configuration file in the current directory. Usually the current directory is the projects root directory with setup.py. I don't want write the temporary configuration file to the current directory of the test process because this could be anyware and can theoretically contain 'setup.cfg'.

I think the directory changing may cause a throuble only when tests are run in parallel threads of the single process. If tests are run in parallel in the different processes (with pytest-xdist for example) it isn't an issue beause each process has its own current directory.

myint commented 8 years ago

Correct me if I am wrong, but doesn't autopep8 search for the parent directories of the Python file (rather than the current working directory)? So,

$ autopep8 foo/bar/something.py

would check foo/bar for a configuration file?

https://github.com/hhatto/autopep8/blob/master/autopep8.py#L3221

I don't actually use this feature myself so I don't remember the exact details.

generalov commented 8 years ago

You are right. autopep8 can search configuration file by filename too. I've added a code in pyformat.py to make it work. I've remove the change_cwd from from test.

myint commented 8 years ago

Thanks!