##// END OF EJS Templates
Merge branch 'main' into UltraTBPR
jsbautista -
r28861:5e33cf39 merge
parent child Browse files
Show More
@@ -10,9 +10,9 b' jobs:'
10 runs-on: ubuntu-latest
10 runs-on: ubuntu-latest
11
11
12 steps:
12 steps:
13 - uses: actions/checkout@v3
13 - uses: actions/checkout@v4
14 - name: Set up Python
14 - name: Set up Python
15 uses: actions/setup-python@v4
15 uses: actions/setup-python@v5
16 with:
16 with:
17 python-version: 3.x
17 python-version: 3.x
18 - name: Install Graphviz
18 - name: Install Graphviz
@@ -34,6 +34,6 b' jobs:'
34 run: |
34 run: |
35 coverage combine `find . -name .coverage\*` && coverage xml
35 coverage combine `find . -name .coverage\*` && coverage xml
36 - name: Upload coverage to Codecov
36 - name: Upload coverage to Codecov
37 uses: codecov/codecov-action@v2
37 uses: codecov/codecov-action@v4
38 with:
38 with:
39 name: Docs
39 name: Docs
@@ -25,9 +25,9 b' jobs:'
25 python-version: "3.10"
25 python-version: "3.10"
26
26
27 steps:
27 steps:
28 - uses: actions/checkout@v3
28 - uses: actions/checkout@v4
29 - name: Set up Python ${{ matrix.python-version }}
29 - name: Set up Python ${{ matrix.python-version }}
30 uses: actions/setup-python@v4
30 uses: actions/setup-python@v5
31 with:
31 with:
32 python-version: ${{ matrix.python-version }}
32 python-version: ${{ matrix.python-version }}
33 - name: Update Python installer
33 - name: Update Python installer
@@ -53,19 +53,21 b' jobs:'
53 pytest
53 pytest
54 - name: Install sagemath-repl
54 - name: Install sagemath-repl
55 run: |
55 run: |
56 cd ..
56 # Sept 2024, sage has been failing for a while,
57 git clone --depth 1 https://github.com/sagemath/sage
57 # Skipping.
58 cd sage
58 # cd ..
59 # We cloned it for the tests, but for simplicity we install the
59 # git clone --depth 1 https://github.com/sagemath/sage
60 # wheels from PyPI.
60 # cd sage
61 # (Avoid 10.3b6 because of https://github.com/sagemath/sage/pull/37178)
61 # # We cloned it for the tests, but for simplicity we install the
62 pip install --pre sagemath-repl sagemath-environment
62 # # wheels from PyPI.
63 # Install optionals that make more tests pass
63 # # (Avoid 10.3b6 because of https://github.com/sagemath/sage/pull/37178)
64 pip install pillow
64 # pip install --pre sagemath-repl sagemath-environment
65 pip install --pre sagemath-categories
65 # # Install optionals that make more tests pass
66 cd ..
66 # pip install pillow
67 # pip install --pre sagemath-categories
68 # cd ..
67 - name: Test sagemath-repl
69 - name: Test sagemath-repl
68 run: |
70 run: |
69 cd ../sage/
71 # cd ../sage/
70 # From https://github.com/sagemath/sage/blob/develop/pkgs/sagemath-repl/tox.ini
72 # # From https://github.com/sagemath/sage/blob/develop/pkgs/sagemath-repl/tox.ini
71 sage-runtests -p --environment=sage.all__sagemath_repl --baseline-stats-path=pkgs/sagemath-repl/known-test-failures.json --initial --optional=sage src/sage/repl src/sage/doctest src/sage/misc/sage_input.py src/sage/misc/sage_eval.py
73 # sage-runtests -p --environment=sage.all__sagemath_repl --baseline-stats-path=pkgs/sagemath-repl/known-test-failures.json --initial --optional=sage src/sage/repl src/sage/doctest src/sage/misc/sage_input.py src/sage/misc/sage_eval.py
@@ -18,9 +18,9 b' jobs:'
18 python-version: ["3.x"]
18 python-version: ["3.x"]
19
19
20 steps:
20 steps:
21 - uses: actions/checkout@v3
21 - uses: actions/checkout@v4
22 - name: Set up Python ${{ matrix.python-version }}
22 - name: Set up Python ${{ matrix.python-version }}
23 uses: actions/setup-python@v4
23 uses: actions/setup-python@v5
24 with:
24 with:
25 python-version: ${{ matrix.python-version }}
25 python-version: ${{ matrix.python-version }}
26 - name: Install dependencies
26 - name: Install dependencies
@@ -13,9 +13,9 b' jobs:'
13 if: github.event_name != 'pull_request' && (github.event_name != 'schedule' || github.repository_owner == 'ipython')
13 if: github.event_name != 'pull_request' && (github.event_name != 'schedule' || github.repository_owner == 'ipython')
14
14
15 steps:
15 steps:
16 - uses: actions/checkout@v3
16 - uses: actions/checkout@v4
17 - name: Set up Python
17 - name: Set up Python
18 uses: actions/setup-python@v4
18 uses: actions/setup-python@v5
19 with:
19 with:
20 python-version: "3.10"
20 python-version: "3.10"
21 cache: pip
21 cache: pip
@@ -18,11 +18,11 b' jobs:'
18 runs-on: ubuntu-latest
18 runs-on: ubuntu-latest
19 timeout-minutes: 5
19 timeout-minutes: 5
20 steps:
20 steps:
21 - uses: actions/checkout@v3
21 - uses: actions/checkout@v4
22 with:
22 with:
23 fetch-depth: 0
23 fetch-depth: 0
24 - name: Set up Python
24 - name: Set up Python
25 uses: actions/setup-python@v4
25 uses: actions/setup-python@v5
26 with:
26 with:
27 python-version: 3.x
27 python-version: 3.x
28 - name: Install dependencies
28 - name: Install dependencies
@@ -56,9 +56,9 b' jobs:'
56 want-latest-entry-point-code: true
56 want-latest-entry-point-code: true
57
57
58 steps:
58 steps:
59 - uses: actions/checkout@v3
59 - uses: actions/checkout@v4
60 - name: Set up Python ${{ matrix.python-version }}
60 - name: Set up Python ${{ matrix.python-version }}
61 uses: actions/setup-python@v4
61 uses: actions/setup-python@v5
62 with:
62 with:
63 python-version: ${{ matrix.python-version }}
63 python-version: ${{ matrix.python-version }}
64 cache: pip
64 cache: pip
@@ -109,7 +109,7 b' jobs:'
109 ./report-*.json
109 ./report-*.json
110
110
111 - name: Upload coverage to Codecov
111 - name: Upload coverage to Codecov
112 uses: codecov/codecov-action@v3
112 uses: codecov/codecov-action@v4
113 with:
113 with:
114 name: Test
114 name: Test
115 files: /home/runner/work/ipython/ipython/coverage.xml
115 files: /home/runner/work/ipython/ipython/coverage.xml
@@ -75,20 +75,29 b' def teardown_module():'
75 shutil.rmtree(TMP_TEST_DIR)
75 shutil.rmtree(TMP_TEST_DIR)
76
76
77
77
78 def setup_environment():
78 # Build decorator that uses the setup_environment/setup_environment
79 """Setup testenvironment for some functions that are tested
79 @pytest.fixture
80 in this module. In particular this functions stores attributes
80 def environment():
81 and other things that we need to stub in some test functions.
82 This needs to be done on a function level and not module level because
83 each testfunction needs a pristine environment.
84 """
85 global oldstuff, platformstuff
81 global oldstuff, platformstuff
86 oldstuff = (env.copy(), os.name, sys.platform, path.get_home_dir, IPython.__file__, os.getcwd())
82 oldstuff = (
83 env.copy(),
84 os.name,
85 sys.platform,
86 path.get_home_dir,
87 IPython.__file__,
88 os.getcwd(),
89 )
87
90
88 def teardown_environment():
91 yield
89 """Restore things that were remembered by the setup_environment function
92
90 """
93 (
91 (oldenv, os.name, sys.platform, path.get_home_dir, IPython.__file__, old_wd) = oldstuff
94 oldenv,
95 os.name,
96 sys.platform,
97 path.get_home_dir,
98 IPython.__file__,
99 old_wd,
100 ) = oldstuff
92 os.chdir(old_wd)
101 os.chdir(old_wd)
93 reload(path)
102 reload(path)
94
103
@@ -96,16 +105,7 b' def teardown_environment():'
96 if key not in oldenv:
105 if key not in oldenv:
97 del env[key]
106 del env[key]
98 env.update(oldenv)
107 env.update(oldenv)
99 if hasattr(sys, 'frozen'):
108 assert not hasattr(sys, "frozen")
100 del sys.frozen
101
102
103 # Build decorator that uses the setup_environment/setup_environment
104 @pytest.fixture
105 def environment():
106 setup_environment()
107 yield
108 teardown_environment()
109
109
110
110
111 with_environment = pytest.mark.usefixtures("environment")
111 with_environment = pytest.mark.usefixtures("environment")
@@ -113,11 +113,11 b' with_environment = pytest.mark.usefixtures("environment")'
113
113
114 @skip_if_not_win32
114 @skip_if_not_win32
115 @with_environment
115 @with_environment
116 def test_get_home_dir_1():
116 def test_get_home_dir_1(monkeypatch):
117 """Testcase for py2exe logic, un-compressed lib
117 """Testcase for py2exe logic, un-compressed lib
118 """
118 """
119 unfrozen = path.get_home_dir()
119 unfrozen = path.get_home_dir()
120 sys.frozen = True
120 monkeypatch.setattr(sys, "frozen", True, raising=False)
121
121
122 #fake filename for IPython.__init__
122 #fake filename for IPython.__init__
123 IPython.__file__ = abspath(join(HOME_TEST_DIR, "Lib/IPython/__init__.py"))
123 IPython.__file__ = abspath(join(HOME_TEST_DIR, "Lib/IPython/__init__.py"))
@@ -128,13 +128,15 b' def test_get_home_dir_1():'
128
128
129 @skip_if_not_win32
129 @skip_if_not_win32
130 @with_environment
130 @with_environment
131 def test_get_home_dir_2():
131 def test_get_home_dir_2(monkeypatch):
132 """Testcase for py2exe logic, compressed lib
132 """Testcase for py2exe logic, compressed lib
133 """
133 """
134 unfrozen = path.get_home_dir()
134 unfrozen = path.get_home_dir()
135 sys.frozen = True
135 monkeypatch.setattr(sys, "frozen", True, raising=False)
136 #fake filename for IPython.__init__
136 # fake filename for IPython.__init__
137 IPython.__file__ = abspath(join(HOME_TEST_DIR, "Library.zip/IPython/__init__.py")).lower()
137 IPython.__file__ = abspath(
138 join(HOME_TEST_DIR, "Library.zip/IPython/__init__.py")
139 ).lower()
138
140
139 home_dir = path.get_home_dir(True)
141 home_dir = path.get_home_dir(True)
140 assert home_dir == unfrozen
142 assert home_dir == unfrozen
@@ -160,22 +162,22 b' def test_get_home_dir_4():'
160
162
161 @skip_win32
163 @skip_win32
162 @with_environment
164 @with_environment
163 def test_get_home_dir_5():
165 def test_get_home_dir_5(monkeypatch):
164 """raise HomeDirError if $HOME is specified, but not a writable dir"""
166 """raise HomeDirError if $HOME is specified, but not a writable dir"""
165 env['HOME'] = abspath(HOME_TEST_DIR+'garbage')
167 env['HOME'] = abspath(HOME_TEST_DIR+'garbage')
166 # set os.name = posix, to prevent My Documents fallback on Windows
168 # set os.name = posix, to prevent My Documents fallback on Windows
167 os.name = 'posix'
169 monkeypatch.setattr(os, "name", "posix")
168 pytest.raises(path.HomeDirError, path.get_home_dir, True)
170 pytest.raises(path.HomeDirError, path.get_home_dir, True)
169
171
170 # Should we stub wreg fully so we can run the test on all platforms?
172 # Should we stub wreg fully so we can run the test on all platforms?
171 @skip_if_not_win32
173 @skip_if_not_win32
172 @with_environment
174 @with_environment
173 def test_get_home_dir_8():
175 def test_get_home_dir_8(monkeypatch):
174 """Using registry hack for 'My Documents', os=='nt'
176 """Using registry hack for 'My Documents', os=='nt'
175
177
176 HOMESHARE, HOMEDRIVE, HOMEPATH, USERPROFILE and others are missing.
178 HOMESHARE, HOMEDRIVE, HOMEPATH, USERPROFILE and others are missing.
177 """
179 """
178 os.name = 'nt'
180 monkeypatch.setattr(os, "name", "nt")
179 # Remove from stub environment all keys that may be set
181 # Remove from stub environment all keys that may be set
180 for key in ['HOME', 'HOMESHARE', 'HOMEDRIVE', 'HOMEPATH', 'USERPROFILE']:
182 for key in ['HOME', 'HOMESHARE', 'HOMEDRIVE', 'HOMEPATH', 'USERPROFILE']:
181 env.pop(key, None)
183 env.pop(key, None)
@@ -194,13 +196,12 b' def test_get_home_dir_8():'
194 assert home_dir == abspath(HOME_TEST_DIR)
196 assert home_dir == abspath(HOME_TEST_DIR)
195
197
196 @with_environment
198 @with_environment
197 def test_get_xdg_dir_0():
199 def test_get_xdg_dir_0(monkeypatch):
198 """test_get_xdg_dir_0, check xdg_dir"""
200 """test_get_xdg_dir_0, check xdg_dir"""
199 reload(path)
201 monkeypatch.setattr(path, "_writable_dir", lambda path: True)
200 path._writable_dir = lambda path: True
202 monkeypatch.setattr(path, "get_home_dir", lambda: "somewhere")
201 path.get_home_dir = lambda : 'somewhere'
203 monkeypatch.setattr(os, "name", "posix")
202 os.name = "posix"
204 monkeypatch.setattr(sys, "platform", "linux2")
203 sys.platform = "linux2"
204 env.pop('IPYTHON_DIR', None)
205 env.pop('IPYTHON_DIR', None)
205 env.pop('IPYTHONDIR', None)
206 env.pop('IPYTHONDIR', None)
206 env.pop('XDG_CONFIG_HOME', None)
207 env.pop('XDG_CONFIG_HOME', None)
@@ -209,44 +210,41 b' def test_get_xdg_dir_0():'
209
210
210
211
211 @with_environment
212 @with_environment
212 def test_get_xdg_dir_1():
213 def test_get_xdg_dir_1(monkeypatch):
213 """test_get_xdg_dir_1, check nonexistent xdg_dir"""
214 """test_get_xdg_dir_1, check nonexistent xdg_dir"""
214 reload(path)
215 monkeypatch.setattr(path, "get_home_dir", lambda: HOME_TEST_DIR)
215 path.get_home_dir = lambda : HOME_TEST_DIR
216 monkeypatch.setattr(os, "name", "posix")
216 os.name = "posix"
217 monkeypatch.setattr(sys, "platform", "linux2")
217 sys.platform = "linux2"
218 env.pop("IPYTHON_DIR", None)
218 env.pop('IPYTHON_DIR', None)
219 env.pop("IPYTHONDIR", None)
219 env.pop('IPYTHONDIR', None)
220 env.pop("XDG_CONFIG_HOME", None)
220 env.pop('XDG_CONFIG_HOME', None)
221 assert path.get_xdg_dir() is None
221 assert path.get_xdg_dir() is None
222
222
223 @with_environment
223 @with_environment
224 def test_get_xdg_dir_2():
224 def test_get_xdg_dir_2(monkeypatch):
225 """test_get_xdg_dir_2, check xdg_dir default to ~/.config"""
225 """test_get_xdg_dir_2, check xdg_dir default to ~/.config"""
226 reload(path)
226 monkeypatch.setattr(path, "get_home_dir", lambda: HOME_TEST_DIR)
227 path.get_home_dir = lambda : HOME_TEST_DIR
227 monkeypatch.setattr(os, "name", "posix")
228 os.name = "posix"
228 monkeypatch.setattr(sys, "platform", "linux2")
229 sys.platform = "linux2"
229 env.pop("IPYTHON_DIR", None)
230 env.pop('IPYTHON_DIR', None)
230 env.pop("IPYTHONDIR", None)
231 env.pop('IPYTHONDIR', None)
231 env.pop("XDG_CONFIG_HOME", None)
232 env.pop('XDG_CONFIG_HOME', None)
232 cfgdir = os.path.join(path.get_home_dir(), ".config")
233 cfgdir=os.path.join(path.get_home_dir(), '.config')
234 if not os.path.exists(cfgdir):
233 if not os.path.exists(cfgdir):
235 os.makedirs(cfgdir)
234 os.makedirs(cfgdir)
236
235
237 assert path.get_xdg_dir() == cfgdir
236 assert path.get_xdg_dir() == cfgdir
238
237
239 @with_environment
238 @with_environment
240 def test_get_xdg_dir_3():
239 def test_get_xdg_dir_3(monkeypatch):
241 """test_get_xdg_dir_3, check xdg_dir not used on non-posix systems"""
240 """test_get_xdg_dir_3, check xdg_dir not used on non-posix systems"""
242 reload(path)
241 monkeypatch.setattr(path, "get_home_dir", lambda: HOME_TEST_DIR)
243 path.get_home_dir = lambda : HOME_TEST_DIR
242 monkeypatch.setattr(os, "name", "nt")
244 os.name = "nt"
243 monkeypatch.setattr(sys, "platform", "win32")
245 sys.platform = "win32"
244 env.pop("IPYTHON_DIR", None)
246 env.pop('IPYTHON_DIR', None)
245 env.pop("IPYTHONDIR", None)
247 env.pop('IPYTHONDIR', None)
246 env.pop("XDG_CONFIG_HOME", None)
248 env.pop('XDG_CONFIG_HOME', None)
247 cfgdir = os.path.join(path.get_home_dir(), ".config")
249 cfgdir=os.path.join(path.get_home_dir(), '.config')
250 os.makedirs(cfgdir, exist_ok=True)
248 os.makedirs(cfgdir, exist_ok=True)
251
249
252 assert path.get_xdg_dir() is None
250 assert path.get_xdg_dir() is None
@@ -281,31 +279,30 b' def test_get_long_path_name():'
281 assert p == "/usr/local"
279 assert p == "/usr/local"
282
280
283
281
284 class TestRaiseDeprecation(unittest.TestCase):
282 @dec.skip_win32 # can't create not-user-writable dir on win
283 @with_environment
284 def test_not_writable_ipdir():
285 tmpdir = tempfile.mkdtemp()
286 os.name = "posix"
287 env.pop("IPYTHON_DIR", None)
288 env.pop("IPYTHONDIR", None)
289 env.pop("XDG_CONFIG_HOME", None)
290 env["HOME"] = tmpdir
291 ipdir = os.path.join(tmpdir, ".ipython")
292 os.mkdir(ipdir, 0o555)
293 try:
294 open(os.path.join(ipdir, "_foo_"), "w", encoding="utf-8").close()
295 except IOError:
296 pass
297 else:
298 # I can still write to an unwritable dir,
299 # assume I'm root and skip the test
300 pytest.skip("I can't create directories that I can't write to")
301
302 with pytest.warns(UserWarning, match="is not a writable location"):
303 ipdir = paths.get_ipython_dir()
304 env.pop("IPYTHON_DIR", None)
285
305
286 @dec.skip_win32 # can't create not-user-writable dir on win
287 @with_environment
288 def test_not_writable_ipdir(self):
289 tmpdir = tempfile.mkdtemp()
290 os.name = "posix"
291 env.pop('IPYTHON_DIR', None)
292 env.pop('IPYTHONDIR', None)
293 env.pop('XDG_CONFIG_HOME', None)
294 env['HOME'] = tmpdir
295 ipdir = os.path.join(tmpdir, '.ipython')
296 os.mkdir(ipdir, 0o555)
297 try:
298 open(os.path.join(ipdir, "_foo_"), "w", encoding="utf-8").close()
299 except IOError:
300 pass
301 else:
302 # I can still write to an unwritable dir,
303 # assume I'm root and skip the test
304 pytest.skip("I can't create directories that I can't write to")
305
306 with self.assertWarnsRegex(UserWarning, 'is not a writable location'):
307 ipdir = paths.get_ipython_dir()
308 env.pop('IPYTHON_DIR', None)
309
306
310 @with_environment
307 @with_environment
311 def test_get_py_filename():
308 def test_get_py_filename():
General Comments 0
You need to be logged in to leave comments. Login now