#42 Fill in tmp_path fixture with pytest < 3.9.0
Merged 3 years ago by smooge. Opened 3 years ago by nphilipp.
nphilipp/mirrors-countme main--old-pytest  into  main

file added
+20
@@ -0,0 +1,20 @@ 

+ import os

+ from pathlib import Path

+ 

+ import pytest

+ 

+ 

+ if [int(x) for x in pytest.__version__.split(".")] < [3, 9, 0]:

+     # the tmp_path fixture is only available in pytest >= 3.9.0

+     @pytest.fixture

+     def tmp_path(tmpdir):

+         return Path(tmpdir)

+ 

+ 

+ @pytest.fixture

+ def tmp_path_cwd(tmp_path):

+     """Return a temporary path and change into it"""

+     old_wd = os.getcwd()

+     os.chdir(tmp_path)

+     yield tmp_path

+     os.chdir(old_wd)

file modified
-9
@@ -1,5 +1,4 @@ 

  import tarfile

- import os

  import sqlite3

  from pathlib import Path

  from typing import Any, List, NamedTuple
@@ -14,14 +13,6 @@ 

  TEST_DATA_DIR = HERE.parent / "test_data"

  

  

- @pytest.fixture

- def tmp_path_cwd(tmp_path):

-     old_wd = os.getcwd()

-     os.chdir(tmp_path)

-     yield tmp_path

-     os.chdir(old_wd)

- 

- 

  def _test_tarfile_factory(tarfile_path):

      """Wrap tarfile.open() context manager for fixtures

  

no initial comment

Metadata Update from @nphilipp:
- Request assigned

3 years ago

Pull-Request has been merged by smooge

3 years ago

Build succeeded.