14
0

Accepting request 827056 from home:jayvdb:py-submit

Replace nose with pytest

OBS-URL: https://build.opensuse.org/request/show/827056
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-lockfile?expand=0&rev=23
This commit is contained in:
Tomáš Chvátal
2020-08-17 06:23:18 +00:00
committed by Git OBS Bridge
parent 0cbee96cdf
commit a5c64b4651
3 changed files with 97 additions and 4 deletions

83
convert-to-unittest.patch Normal file
View File

@@ -0,0 +1,83 @@
diff -ur lockfile-0.12.2-orig/test/compliancetest.py lockfile-0.12.2/test/compliancetest.py
--- lockfile-0.12.2-orig/test/compliancetest.py 2015-11-26 01:29:13.000000000 +0700
+++ lockfile-0.12.2/test/compliancetest.py 2020-08-16 07:58:15.176973406 +0700
@@ -1,23 +1,22 @@
import os
import threading
import shutil
+import unittest
import lockfile
class ComplianceTest(object):
- def __init__(self):
- self.saved_class = lockfile.LockFile
-
def _testfile(self):
"""Return platform-appropriate file. Helper for tests."""
import tempfile
return os.path.join(tempfile.gettempdir(), 'trash-%s' % os.getpid())
- def setup(self):
- lockfile.LockFile = self.class_to_test
+ def setUp(self):
+ self.saved_class = lockfile.LockFile
+ lockfile.LockFile = getattr(self, 'class_to_test', None)
- def teardown(self):
+ def tearDown(self):
try:
tf = self._testfile()
if os.path.isdir(tf):
diff -ur lockfile-0.12.2-orig/test/test_lockfile.py lockfile-0.12.2/test/test_lockfile.py
--- lockfile-0.12.2-orig/test/test_lockfile.py 2015-11-26 01:29:13.000000000 +0700
+++ lockfile-0.12.2/test/test_lockfile.py 2020-08-16 07:58:49.461371422 +0700
@@ -1,3 +1,5 @@
+import unittest
+
import lockfile.linklockfile
import lockfile.mkdirlockfile
import lockfile.pidlockfile
@@ -6,28 +8,28 @@
from compliancetest import ComplianceTest
-class TestLinkLockFile(ComplianceTest):
+class TestLinkLockFile(ComplianceTest, unittest.TestCase):
class_to_test = lockfile.linklockfile.LinkLockFile
-class TestSymlinkLockFile(ComplianceTest):
+class TestSymlinkLockFile(ComplianceTest, unittest.TestCase):
class_to_test = lockfile.symlinklockfile.SymlinkLockFile
-class TestMkdirLockFile(ComplianceTest):
+class TestMkdirLockFile(ComplianceTest, unittest.TestCase):
class_to_test = lockfile.mkdirlockfile.MkdirLockFile
-class TestPIDLockFile(ComplianceTest):
+class TestPIDLockFile(ComplianceTest, unittest.TestCase):
class_to_test = lockfile.pidlockfile.PIDLockFile
# Check backwards compatibility
-class TestLinkFileLock(ComplianceTest):
+class TestLinkFileLock(ComplianceTest, unittest.TestCase):
class_to_test = lockfile.LinkFileLock
-class TestMkdirFileLock(ComplianceTest):
+class TestMkdirFileLock(ComplianceTest, unittest.TestCase):
class_to_test = lockfile.MkdirFileLock
try:
@@ -37,5 +39,5 @@
else:
import lockfile.sqlitelockfile
- class TestSQLiteLockFile(ComplianceTest):
+ class TestSQLiteLockFile(ComplianceTest, unittest.TestCase):
class_to_test = lockfile.sqlitelockfile.SQLiteLockFile

View File

@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Sun Aug 16 15:16:13 UTC 2020 - John Vandenberg <jayvdb@gmail.com>
- Add convert-to-unittest.patch to switch from nose to pytest
- Add %fdupes
-------------------------------------------------------------------
Mon Feb 25 21:54:28 UTC 2019 - John Vandenberg <jayvdb@gmail.com>

View File

@@ -1,7 +1,7 @@
#
# spec file for package python-lockfile
#
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2020 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -26,9 +26,11 @@ Group: Development/Languages/Python
URL: https://github.com/openstack/pylockfile
Source: https://files.pythonhosted.org/packages/source/l/lockfile/lockfile-%{version}.tar.gz
Patch0: %{name}-empty_ident.patch
BuildRequires: %{python_module nose}
Patch1: convert-to-unittest.patch
BuildRequires: %{python_module pbr}
BuildRequires: %{python_module pytest}
BuildRequires: %{python_module setuptools}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
BuildArch: noarch
%python_subpackages
@@ -47,16 +49,18 @@ production-quality code.
%setup -q -n lockfile-%{version}
# current thread has ident = None, which causes a TypeError
# http://code.google.com/p/pylockfile/issues/detail?id=8
%patch0 -p1 -b .empty_ident
%patch0 -p1
%patch1 -p1
%build
%python_build
%install
%python_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%check
%python_exec -m nose
%pytest
%files %{python_files}
%license LICENSE