summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2024-02-25 20:16:51 +0100
committerElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2024-02-25 20:16:51 +0100
commit2f4a229b7af6cbb4955ad57ed4769eab3f17bedc (patch)
tree0665db87db6c620ab54f88dc85aa181aa1aa18f5 /tests
parent70ed1dcf05aa9cd7e3c03afd47625dc8a75ab556 (diff)
Remove compatibility helper for python < 3.8
Diffstat (limited to 'tests')
-rw-r--r--tests/test_collection.py18
-rw-r--r--tests/test_commands.py9
-rw-r--r--tests/test_derivatives.py5
-rw-r--r--tests/utils.py18
4 files changed, 14 insertions, 36 deletions
diff --git a/tests/test_collection.py b/tests/test_collection.py
index 63f89d2..dcc2196 100644
--- a/tests/test_collection.py
+++ b/tests/test_collection.py
@@ -11,13 +11,11 @@ import ruamel.yaml
import lesana
-from . import utils
-
class testEntries(unittest.TestCase):
def setUp(self):
self.tmpdir = tempfile.TemporaryDirectory()
- utils.copytree(
+ shutil.copytree(
'tests/data/simple',
self.tmpdir.name,
dirs_exist_ok=True
@@ -141,7 +139,7 @@ class testEntries(unittest.TestCase):
class testEmptyCollection(unittest.TestCase):
def setUp(self):
self.tmpdir = tempfile.TemporaryDirectory()
- utils.copytree(
+ shutil.copytree(
'tests/data/empty',
self.tmpdir.name,
dirs_exist_ok=True
@@ -162,7 +160,7 @@ class testEmptyCollection(unittest.TestCase):
class testSimpleCollection(unittest.TestCase):
def setUp(self):
self.tmpdir = tempfile.TemporaryDirectory()
- utils.copytree(
+ shutil.copytree(
'tests/data/simple',
self.tmpdir.name,
dirs_exist_ok=True
@@ -385,7 +383,7 @@ class testSimpleCollection(unittest.TestCase):
class testComplexCollection(unittest.TestCase):
def setUp(self):
self.tmpdir = tempfile.TemporaryDirectory()
- utils.copytree(
+ shutil.copytree(
'tests/data/complex',
self.tmpdir.name,
dirs_exist_ok=True
@@ -586,7 +584,7 @@ class testComplexCollection(unittest.TestCase):
class testCollectionWithErrors(unittest.TestCase):
def setUp(self):
self.tmpdir = tempfile.TemporaryDirectory()
- utils.copytree(
+ shutil.copytree(
'tests/data/wrong',
self.tmpdir.name,
dirs_exist_ok=True
@@ -749,7 +747,7 @@ class testCollectionCreation(unittest.TestCase):
def test_deletion(self):
shutil.copy('tests/data/simple/settings.yaml', self.tmpdir.name)
- utils.copytree(
+ shutil.copytree(
'tests/data/simple/items', os.path.join(self.tmpdir.name, 'items'),
)
collection = lesana.Collection.init(self.tmpdir.name)
@@ -775,7 +773,7 @@ class testCollectionCreation(unittest.TestCase):
def test_partial_eid_deletion(self):
shutil.copy('tests/data/simple/settings.yaml', self.tmpdir.name)
- utils.copytree(
+ shutil.copytree(
'tests/data/simple/items', os.path.join(self.tmpdir.name, 'items'),
)
collection = lesana.Collection.init(self.tmpdir.name)
@@ -809,7 +807,7 @@ class testCollectionCreation(unittest.TestCase):
def test_git_adding(self):
shutil.copy('tests/data/simple/settings.yaml', self.tmpdir.name)
- utils.copytree(
+ shutil.copytree(
'tests/data/simple/items', os.path.join(self.tmpdir.name, 'items'),
)
collection = lesana.Collection.init(self.tmpdir.name)
diff --git a/tests/test_commands.py b/tests/test_commands.py
index 17966b7..6606e5b 100644
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -1,6 +1,7 @@
import contextlib
import io
import os
+import shutil
import tempfile
import unittest
@@ -8,8 +9,6 @@ import hazwaz.unittest
from lesana import command
-from . import utils
-
class Args:
def __init__(self, args):
@@ -45,7 +44,7 @@ class CommandsMixin:
class testCommandsSimple(hazwaz.unittest.HazwazTestCase, CommandsMixin):
def setUp(self):
self.tmpdir = tempfile.TemporaryDirectory()
- utils.copytree(
+ shutil.copytree(
'tests/data/simple',
self.tmpdir.name,
dirs_exist_ok=True,
@@ -141,7 +140,7 @@ class testCommandsSimple(hazwaz.unittest.HazwazTestCase, CommandsMixin):
def test_export(self):
with tempfile.TemporaryDirectory() as dest_tmpdir:
- utils.copytree(
+ shutil.copytree(
'tests/data/simple',
dest_tmpdir,
dirs_exist_ok=True,
@@ -197,7 +196,7 @@ class testCommandsSimple(hazwaz.unittest.HazwazTestCase, CommandsMixin):
class testCommandsComplex(hazwaz.unittest.HazwazTestCase, CommandsMixin):
def setUp(self):
self.tmpdir = tempfile.TemporaryDirectory()
- utils.copytree(
+ shutil.copytree(
'tests/data/complex',
self.tmpdir.name,
dirs_exist_ok=True,
diff --git a/tests/test_derivatives.py b/tests/test_derivatives.py
index ba9d79c..a97a80f 100644
--- a/tests/test_derivatives.py
+++ b/tests/test_derivatives.py
@@ -1,11 +1,10 @@
+import shutil
import tempfile
import unittest
import lesana
from lesana import types
-from . import utils
-
class DerivedType(types.LesanaString):
"""
@@ -23,7 +22,7 @@ class Derivative(lesana.Collection):
class testDerivatives(unittest.TestCase):
def setUp(self):
self.tmpdir = tempfile.TemporaryDirectory()
- utils.copytree(
+ shutil.copytree(
'tests/data/derivative',
self.tmpdir.name,
dirs_exist_ok=True
diff --git a/tests/utils.py b/tests/utils.py
deleted file mode 100644
index a56a120..0000000
--- a/tests/utils.py
+++ /dev/null
@@ -1,18 +0,0 @@
-import shutil
-import sys
-
-
-def copytree(src, dest, dirs_exist_ok=False):
- """
- Helper function to remove existing directories
-
- Used in the tests for compatibility with python < 3.8
- """
- if sys.version_info >= (3, 8):
- shutil.copytree(src, dest, dirs_exist_ok=dirs_exist_ok)
- else:
- if dirs_exist_ok:
- if not dest.startswith('/tmp'):
- raise ValueError("Refusing to delete a directory outside /tmp")
- shutil.rmtree(dest)
- shutil.copytree(src, dest)