File: use_tmp_path.patch

package info (click to toggle)
statsmodels 0.14.5%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 49,940 kB
  • sloc: python: 253,284; f90: 612; sh: 560; javascript: 337; asm: 156; makefile: 145; ansic: 16; xml: 9
file content (65 lines) | stat: -rw-r--r-- 2,548 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
Description: Don't try to write to the source directory

Not allowed in autopkgtest

Author: Rebecca N. Palmer <rebecca_palmer@zoho.com>
Forwarded: no

--- a/statsmodels/datasets/tests/test_utils.py
+++ b/statsmodels/datasets/tests/test_utils.py
@@ -9,8 +9,6 @@ import pytest
 from statsmodels.compat.python import PYTHON_IMPL_WASM
 from statsmodels.datasets import get_rdataset, webuse, check_internet, utils
 
-cur_dir = os.path.dirname(os.path.abspath(__file__))
-
 IGNORED_EXCEPTIONS = (HTTPError, URLError, UnicodeEncodeError, timeout)
 if not PYTHON_IMPL_WASM:
     from ssl import SSLError
@@ -18,38 +16,38 @@ if not PYTHON_IMPL_WASM:
 
 
 @pytest.mark.smoke
-def test_get_rdataset():
+def test_get_rdataset(tmp_path):
     test_url = "https://raw.githubusercontent.com/vincentarelbundock/" \
                "Rdatasets/master/csv/datasets/cars.csv"
     internet_available = check_internet(test_url)
     if not internet_available:  # pragma: no cover
         pytest.skip('Unable to retrieve file - skipping test')
     try:
-        duncan = get_rdataset("Duncan", "carData", cache=cur_dir)
+        duncan = get_rdataset("Duncan", "carData", cache=tmp_path)
     except IGNORED_EXCEPTIONS:
         pytest.skip('Failed with HTTPError or URLError, these are random')
     assert_(isinstance(duncan, utils.Dataset))
-    duncan = get_rdataset("Duncan", "carData", cache=cur_dir)
+    duncan = get_rdataset("Duncan", "carData", cache=tmp_path)
     assert_(duncan.from_cache)
 
 
 @pytest.mark.smoke
-def test_get_rdataset_write_read_cache():
+def test_get_rdataset_write_read_cache(tmp_path):
     # test writing and reading cache
     try:
-        guerry = get_rdataset("Guerry", "HistData", cache=cur_dir)
+        guerry = get_rdataset("Guerry", "HistData", cache=tmp_path)
     except IGNORED_EXCEPTIONS:
         pytest.skip('Failed with HTTPError or URLError, these are random')
 
     assert_(guerry.from_cache is False)
-    guerry2 = get_rdataset("Guerry", "HistData", cache=cur_dir)
+    guerry2 = get_rdataset("Guerry", "HistData", cache=tmp_path)
     assert_(guerry2.from_cache is True)
     fn = "raw.githubusercontent.com,vincentarelbundock,Rdatasets,master,csv," \
          "HistData,Guerry-v2.csv.zip"
-    os.remove(os.path.join(cur_dir, fn))
+    os.remove(os.path.join(tmp_path, fn))
     fn = "raw.githubusercontent.com,vincentarelbundock,Rdatasets,master,doc," \
          "HistData,rst,Guerry-v2.rst.zip"
-    os.remove(os.path.join(cur_dir, fn))
+    os.remove(os.path.join(tmp_path, fn))
 
 
 def test_webuse():