laike9m / pdir2

Pretty dir() printing with joy:beer:
MIT License
1.32k stars 47 forks source link

XONSH support #29

Open tkossak opened 7 years ago

tkossak commented 7 years ago

Hi,

I forked this repo and tried adding support to xonsh shell but i have problems with tests. Can someone more experienced with python/pytest look at these errors and tell me if I did something wrong (and what)?

Xonsh must be treated similarly to ptpython, so PrettyDir.__repr__() method should print self.repr_str not return it (just like for ptpython). So I made small changes in https://github.com/tkossak/pdir2/commit/24c43ba9bb05b732c66ae09e665dbb5dc4f0e95c and it works for me. The problem is with tests, which now return these errors. For me it seems like for xonsh and ptpython this assert: result.repr_str == repr(result) should always fail because __repr__() always returns null string for these shells. If so, why the tests work for ptpython and not for xonsh?

Thank you.

laike9m commented 7 years ago

Actually no tests is run in ptpython, the only test that is written for ptpython is https://github.com/laike9m/pdir2/blob/master/tests/interactive_test.py which doesn't even have an assert statement.

I've not used xonsh before, but if it's only a different shell, tests shouldn't break. Could you tell me what commands you typed and how you run tests?

tkossak commented 7 years ago

I run tests by typing pytest or pytest -v. I tried these commands both in xonsh and in bash and they end the same (with errors). The line that is causing problems is api.py:45. If I change this one line to original, all the tests pass successfully.

Maybe I invoke pytest wrongly, and these tests shouldn't run at all for xonsh (you said they don't run for ptpython either).

Xonsh is python shell (you can run all python commands directly in it).

laike9m commented 7 years ago

@tkossak Thanks for opening this issue.

After playing with xnosh a bit, I don't think it's easy to get pdir2 working on it. As there're many features of higher priority there, I won't put much effort into this in the near future. However, I still encourage you to go deeper to find out the root cause, because in most cases it's the REPL's inconsistency with others that caused problems, like this one.

tkossak commented 7 years ago

I'll try to figure out why tests fail, but i actually use pdir2 withy this change and it works perfectly fine under xonsh, ipython and python.

laike9m commented 7 years ago

Alright, that's good to hear.