Repository navigation
Closed as not planned
Labels
Description
I am having problem passing this test:
ipython/IPython/core/tests/test_paths.py
Lines 57 to 69 in 3c2c185
def test_get_ipython_dir_2(): """test_get_ipython_dir_2, Testcase to see if we can call get_ipython_dir without Exceptions.""" with patch_get_home_dir('someplace'), \ patch.object(paths, 'get_xdg_dir', return_value=None), \ patch.object(paths, '_writable_dir', return_value=True), \ patch('os.name', "posix"), \ modified_env({'IPYTHON_DIR': None, 'IPYTHONDIR': None, 'XDG_CONFIG_HOME': None }): ipdir = paths.get_ipython_dir() nt.assert_equal(ipdir, os.path.join("someplace", ".ipython"))
And others similar.
The problem is this line: patch('os.name', "posix"). Because pathlib thinks it is running into a unix system then tries to use PosixPath.
Therefore it gets this error:
====================================================================== ERROR: test_get_ipython_dir_2, Testcase to see if we can call get_ipython_dir without Exceptions. ---------------------------------------------------------------------- Traceback (most recent call last): File "C:\Users\David\Envs\ipy\lib\site-packages\nose\case.py", line 198, in runTest self.test(*self.arg) File "c:\users\david\proyectos\ipython\IPython\core\tests\test_paths.py", line 67, in test_get_ipython_dir_2 ipdir = paths.get_ipython_dir() File "c:\users\david\proyectos\ipython\IPython\paths.py", line 45, in get_ipython_dir ipdir = Path(home_dir, ipdir_def) File "c:\python\python38\lib\pathlib.py", line 1035, in __new__ raise NotImplementedError("cannot instantiate %r on your system" NotImplementedError: cannot instantiate 'PosixPath' on your system
@Carreau what should I do?
Originally posted by @davbrito in #12650 (comment)
Activity
[-]I am having problem passing [this test](https://github.com/ipython/ipython/blob/3c2c1857268fba1833b324d8b4e4ce53b0220b83/IPython/core/tests/test_paths.py#L57), and others similar.[/-][+]Problem with tests test_get_ipython_dir_* when using pathlib[/+]davbrito commentedon Oct 19, 2020
@meeseeksdev tag help wanted
davbrito commentedon Oct 19, 2020
@meeseeksdev tag testing
lumberbot-app commentedon Oct 19, 2020
Aww davbrito, I was not able to apply the following label(s):
testing. Either because they are not existing labels on this repository or because you do not have the permission to apply these.I tried my best to guess by looking at the casing, but was unable to find matching labels.MrMino commentedon Oct 20, 2020
Patching
os.nameintoposixis not a good idea IMO, especially since builtins depend on its value.davbrito commentedon Oct 20, 2020
Why do they do it in those tests? Is there any justification for that?