15
0
forked from pool/python-cepa

- Add patch fix-assertions.patch:

* Use correct assertion functions.
- Stop skipping Python 3.12.

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-cepa?expand=0&rev=10
This commit is contained in:
2024-12-05 05:09:58 +00:00
committed by Git OBS Bridge
commit f644369567
8 changed files with 1203 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
.osc

3
cepa-1.8.4.tar.gz Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:3fbc701ac3fc89cd7f69bc58a6d0d735b014fa40b61e2c2efd381ed20db58a96
size 2862540

221
fix-assertions.patch Normal file
View File

@@ -0,0 +1,221 @@
Index: cepa-1.8.4/test/integ/descriptor/collector.py
===================================================================
--- cepa-1.8.4.orig/test/integ/descriptor/collector.py
+++ cepa-1.8.4/test/integ/descriptor/collector.py
@@ -88,7 +88,7 @@ class TestCollector(unittest.TestCase):
)
for args, expected_msg in test_values:
- self.assertRaisesRegexp(ValueError, re.escape(expected_msg), list, stem.descriptor.collector.get_consensus(**args))
+ self.assertRaisesRegex(ValueError, re.escape(expected_msg), list, stem.descriptor.collector.get_consensus(**args))
def _test_index(self, compression):
if compression and not compression.available:
Index: cepa-1.8.4/test/unit/client/cell.py
===================================================================
--- cepa-1.8.4.orig/test/unit/client/cell.py
+++ cepa-1.8.4/test/unit/client/cell.py
@@ -213,7 +213,7 @@ class TestCell(unittest.TestCase):
self.assertEqual(3257622417, RelayCell(5, 'RELAY_BEGIN_DIR', '', digest.digest(), 564346860).digest)
self.assertEqual(3257622417, RelayCell(5, 'RELAY_BEGIN_DIR', '', 3257622417, 564346860).digest)
self.assertRaisesWith(ValueError, 'RELAY cell digest must be a hash, string, or int but was a list', RelayCell, 5, 'RELAY_BEGIN_DIR', '', [], 564346860)
- self.assertRaisesRegexp(ValueError, "Invalid enumeration 'NO_SUCH_COMMAND', options are RELAY_BEGIN, RELAY_DATA", RelayCell, 5, 'NO_SUCH_COMMAND', '', 5, 564346860)
+ self.assertRaisesRegex(ValueError, "Invalid enumeration 'NO_SUCH_COMMAND', options are RELAY_BEGIN, RELAY_DATA", RelayCell, 5, 'NO_SUCH_COMMAND', '', 5, 564346860)
mismatched_data_length_bytes = b''.join((
b'\x00\x01', # circ ID
Index: cepa-1.8.4/test/unit/client/size.py
===================================================================
--- cepa-1.8.4.orig/test/unit/client/size.py
+++ cepa-1.8.4/test/unit/client/size.py
@@ -28,7 +28,7 @@ class TestSize(unittest.TestCase):
self.assertRaisesWith(ValueError, 'Packed values must be positive (attempted to pack -1 as a CHAR)', Size.CHAR.pack, -1)
bad_size = Size('BAD_SIZE', 1, '!H')
- self.assertRaisesRegexp(ValueError, re.escape("'\\x00\\x12' is the wrong size for a BAD_SIZE field"), bad_size.pack, 18)
+ self.assertRaisesRegex(ValueError, re.escape("'\\x00\\x12' is the wrong size for a BAD_SIZE field"), bad_size.pack, 18)
def test_unpack(self):
self.assertEqual(18, Size.CHAR.unpack(b'\x12'))
Index: cepa-1.8.4/test/unit/descriptor/certificate.py
===================================================================
--- cepa-1.8.4.orig/test/unit/descriptor/certificate.py
+++ cepa-1.8.4/test/unit/descriptor/certificate.py
@@ -119,7 +119,7 @@ class TestEd25519Certificate(unittest.Te
"""
exc_msg = re.escape("Ed25519 certificate wasn't propoerly base64 encoded (Incorrect padding):")
- self.assertRaisesRegexp(ValueError, exc_msg, Ed25519Certificate.from_base64, '\x02\x0323\x04')
+ self.assertRaisesRegex(ValueError, exc_msg, Ed25519Certificate.from_base64, '\x02\x0323\x04')
def test_too_short(self):
"""
Index: cepa-1.8.4/test/unit/descriptor/collector.py
===================================================================
--- cepa-1.8.4.orig/test/unit/descriptor/collector.py
+++ cepa-1.8.4/test/unit/descriptor/collector.py
@@ -107,13 +107,13 @@ class TestCollector(unittest.TestCase):
urlopen_mock.side_effect = IOError('boom')
collector = CollecTor(retries = 0)
- self.assertRaisesRegexp(IOError, 'boom', collector.index)
+ self.assertRaisesRegex(IOError, 'boom', collector.index)
self.assertEqual(1, urlopen_mock.call_count)
urlopen_mock.reset_mock()
collector = CollecTor(retries = 4)
- self.assertRaisesRegexp(IOError, 'boom', collector.index)
+ self.assertRaisesRegex(IOError, 'boom', collector.index)
self.assertEqual(5, urlopen_mock.call_count)
@patch(URL_OPEN, Mock(return_value = io.BytesIO(b'not json')))
@@ -121,7 +121,7 @@ class TestCollector(unittest.TestCase):
collector = CollecTor()
if stem.prereq.is_python_3():
- self.assertRaisesRegexp(ValueError, 'Expecting value: line 1 column 1', collector.index, Compression.PLAINTEXT)
+ self.assertRaisesRegex(ValueError, 'Expecting value: line 1 column 1', collector.index, Compression.PLAINTEXT)
else:
self.assertRaisesRegexp(ValueError, 'No JSON object could be decoded', collector.index, Compression.PLAINTEXT)
@@ -132,7 +132,7 @@ class TestCollector(unittest.TestCase):
with patch(URL_OPEN, Mock(return_value = io.BytesIO(b'not compressed'))):
collector = CollecTor()
- self.assertRaisesRegexp(IOError, 'Failed to decompress as %s' % compression, collector.index, compression)
+ self.assertRaisesRegex(IOError, 'Failed to decompress as %s' % compression, collector.index, compression)
@patch('stem.descriptor.collector.CollecTor.index', Mock(return_value = EXAMPLE_INDEX))
def test_files(self):
Index: cepa-1.8.4/test/unit/descriptor/remote.py
===================================================================
--- cepa-1.8.4.orig/test/unit/descriptor/remote.py
+++ cepa-1.8.4/test/unit/descriptor/remote.py
@@ -159,7 +159,7 @@ class TestDescriptorDownloader(unittest.
validate = True,
)
- self.assertRaisesRegexp(stem.ProtocolError, "^Response should begin with HTTP success, but was 'HTTP/1.0 500 Kaboom'", request.run)
+ self.assertRaisesRegex(stem.ProtocolError, "^Response should begin with HTTP success, but was 'HTTP/1.0 500 Kaboom'", request.run)
@patch(URL_OPEN, _dirport_mock(TEST_DESCRIPTOR))
def test_using_dirport(self):
Index: cepa-1.8.4/test/unit/directory/authority.py
===================================================================
--- cepa-1.8.4.orig/test/unit/directory/authority.py
+++ cepa-1.8.4/test/unit/directory/authority.py
@@ -75,4 +75,4 @@ class TestAuthority(unittest.TestCase):
@patch(URL_OPEN, Mock(return_value = io.BytesIO(b'')))
def test_from_remote_empty(self):
- self.assertRaisesRegexp(stem.DownloadFailed, 'no content', stem.directory.Authority.from_remote)
+ self.assertRaisesRegex(stem.DownloadFailed, 'no content', stem.directory.Authority.from_remote)
Index: cepa-1.8.4/test/unit/directory/fallback.py
===================================================================
--- cepa-1.8.4.orig/test/unit/directory/fallback.py
+++ cepa-1.8.4/test/unit/directory/fallback.py
@@ -120,15 +120,15 @@ class TestFallback(unittest.TestCase):
@patch(URL_OPEN, Mock(return_value = io.BytesIO(b'')))
def test_from_remote_empty(self):
- self.assertRaisesRegexp(stem.DownloadFailed, 'no content', stem.directory.Fallback.from_remote)
+ self.assertRaisesRegex(stem.DownloadFailed, 'no content', stem.directory.Fallback.from_remote)
@patch(URL_OPEN, Mock(return_value = io.BytesIO(b'\n'.join(FALLBACK_GITWEB_CONTENT.splitlines()[1:]))))
def test_from_remote_no_header(self):
- self.assertRaisesRegexp(IOError, 'does not have a type field indicating it is fallback directory metadata', stem.directory.Fallback.from_remote)
+ self.assertRaisesRegex(IOError, 'does not have a type field indicating it is fallback directory metadata', stem.directory.Fallback.from_remote)
@patch(URL_OPEN, Mock(return_value = io.BytesIO(FALLBACK_GITWEB_CONTENT.replace(b'version=2.0.0', b'version'))))
def test_from_remote_malformed_header(self):
- self.assertRaisesRegexp(IOError, 'Malformed fallback directory header line: /\\* version \\*/', stem.directory.Fallback.from_remote)
+ self.assertRaisesRegex(IOError, 'Malformed fallback directory header line: /\\* version \\*/', stem.directory.Fallback.from_remote)
def test_from_remote_malformed(self):
test_values = {
@@ -142,7 +142,7 @@ class TestFallback(unittest.TestCase):
for entry, expected in test_values.items():
with patch(URL_OPEN, Mock(return_value = io.BytesIO(entry))):
- self.assertRaisesRegexp(IOError, re.escape(expected), stem.directory.Fallback.from_remote)
+ self.assertRaisesRegex(IOError, re.escape(expected), stem.directory.Fallback.from_remote)
def test_persistence(self):
expected = {
Index: cepa-1.8.4/test/unit/response/add_onion.py
===================================================================
--- cepa-1.8.4.orig/test/unit/response/add_onion.py
+++ cepa-1.8.4/test/unit/response/add_onion.py
@@ -89,7 +89,7 @@ class TestAddOnionResponse(unittest.Test
"""
response = ControlMessage.from_str(WRONG_FIRST_KEY, normalize = True)
- self.assertRaisesRegexp(stem.ProtocolError, 'ADD_ONION response should start with', stem.response.convert, 'ADD_ONION', response)
+ self.assertRaisesRegex(stem.ProtocolError, 'ADD_ONION response should start with', stem.response.convert, 'ADD_ONION', response)
def test_no_key_type(self):
"""
@@ -97,4 +97,4 @@ class TestAddOnionResponse(unittest.Test
"""
response = ControlMessage.from_str(MISSING_KEY_TYPE, normalize = True)
- self.assertRaisesRegexp(stem.ProtocolError, 'ADD_ONION PrivateKey lines should be of the form', stem.response.convert, 'ADD_ONION', response)
+ self.assertRaisesRegex(stem.ProtocolError, 'ADD_ONION PrivateKey lines should be of the form', stem.response.convert, 'ADD_ONION', response)
Index: cepa-1.8.4/test/unit/util/connection.py
===================================================================
--- cepa-1.8.4.orig/test/unit/util/connection.py
+++ cepa-1.8.4/test/unit/util/connection.py
@@ -198,12 +198,12 @@ class TestConnection(unittest.TestCase):
def test_download_retries(self, urlopen_mock):
urlopen_mock.side_effect = urllib.URLError('boom')
- self.assertRaisesRegexp(IOError, 'boom', stem.util.connection.download, URL)
+ self.assertRaisesRegex(IOError, 'boom', stem.util.connection.download, URL)
self.assertEqual(1, urlopen_mock.call_count)
urlopen_mock.reset_mock()
- self.assertRaisesRegexp(IOError, 'boom', stem.util.connection.download, URL, retries = 4)
+ self.assertRaisesRegex(IOError, 'boom', stem.util.connection.download, URL, retries = 4)
self.assertEqual(5, urlopen_mock.call_count)
@patch('os.access')
Index: cepa-1.8.4/test/unit/version.py
===================================================================
--- cepa-1.8.4.orig/test/unit/version.py
+++ cepa-1.8.4/test/unit/version.py
@@ -58,7 +58,7 @@ class TestVersion(unittest.TestCase):
Tor version output that doesn't include a version within it.
"""
- self.assertRaisesRegexp(IOError, "'tor_unit --version' didn't provide a parseable version", stem.version.get_system_tor_version, 'tor_unit')
+ self.assertRaisesRegex(IOError, "'tor_unit --version' didn't provide a parseable version", stem.version.get_system_tor_version, 'tor_unit')
@patch('stem.util.system.call', Mock(return_value = MALFORMED_TOR_VERSION.splitlines()))
@patch.dict(stem.version.VERSION_CACHE)
Index: cepa-1.8.4/stem/util/test_tools.py
===================================================================
--- cepa-1.8.4.orig/stem/util/test_tools.py
+++ cepa-1.8.4/stem/util/test_tools.py
@@ -285,17 +285,10 @@ class TimedTestRunner(unittest.TextTestR
vended API then please let us know.
"""
- return self.assertRaisesRegexp(exc_type, '^%s$' % re.escape(exc_msg), func, *args, **kwargs)
+ return self.assertRaisesRegex(exc_type, '^%s$' % re.escape(exc_msg), func, *args, **kwargs)
- def assertRaisesRegexp(self, exc_type, exc_msg, func, *args, **kwargs):
- if stem.prereq._is_python_26():
- try:
- func(*args, **kwargs)
- self.fail('Expected a %s to be raised but nothing was' % exc_type)
- except exc_type as exc:
- self.assertTrue(re.search(exc_msg, str(exc), re.MULTILINE))
- else:
- return super(original_type, self).assertRaisesRegexp(exc_type, exc_msg, func, *args, **kwargs)
+ def assertRaisesRegex(self, exc_type, exc_msg, func, *args, **kwargs):
+ return super(original_type, self).assertRaisesRegex(exc_type, exc_msg, func, *args, **kwargs)
def id(self):
return '%s.%s.%s' % (original_type.__module__, original_type.__name__, self._testMethodName)

802
mock.patch Normal file
View File

@@ -0,0 +1,802 @@
+From 5691ff000a40059a2a9812e627574ac88cc7c754 Mon Sep 17 00:00:00 2001
From: Damian Johnson <atagar@torproject.org>
Date: Fri, 3 Jan 2020 15:54:22 -0800
Subject: [PATCH] Drop mock fallback
Python 3.3 added mock as a builtin. As such we no longer need to use python
2.x's standalone mock module as a fallback.
---
run_tests.py | 15 --------
stem/prereq.py | 43 -----------------------
test/integ/connection/connect.py | 8 ++---
test/integ/process.py | 8 ++---
test/integ/response/protocolinfo.py | 6 +---
test/integ/util/system.py | 8 ++---
test/task.py | 2 --
test/unit/connection/authentication.py | 8 ++---
test/unit/connection/connect.py | 15 ++++----
test/unit/control/controller.py | 8 ++---
test/unit/descriptor/bandwidth_file.py | 8 ++---
test/unit/descriptor/collector.py | 8 ++---
test/unit/descriptor/hidden_service_v3.py | 8 ++---
test/unit/descriptor/reader.py | 6 +---
test/unit/descriptor/remote.py | 8 ++---
test/unit/descriptor/server_descriptor.py | 8 ++---
test/unit/directory/authority.py | 6 +---
test/unit/directory/fallback.py | 6 +---
test/unit/doctest.py | 8 ++---
test/unit/exit_policy/policy.py | 6 +---
test/unit/interpreter/__init__.py | 6 +---
test/unit/interpreter/autocomplete.py | 9 ++---
test/unit/interpreter/commands.py | 8 ++---
test/unit/manual.py | 8 ++---
test/unit/response/events.py | 8 ++---
test/unit/response/protocolinfo.py | 8 ++---
test/unit/tutorial.py | 8 ++---
test/unit/tutorial_examples.py | 8 ++---
test/unit/util/connection.py | 8 ++---
test/unit/util/proc.py | 7 ++--
test/unit/util/system.py | 8 ++---
test/unit/version.py | 8 ++---
32 files changed, 56 insertions(+), 231 deletions(-)
Index: stem-1.8.0/run_tests.py
===================================================================
--- stem-1.8.0.orig/run_tests.py
+++ stem-1.8.0/run_tests.py
@@ -194,20 +194,6 @@ def main():
println('Nothing to run (for usage provide --help)\n')
sys.exit()
- if not stem.prereq.is_mock_available():
- try:
- import mock
- println(MOCK_OUT_OF_DATE_MSG % mock.__version__)
- except ImportError:
- println(MOCK_UNAVAILABLE_MSG)
-
- if stem.util.system.is_available('pip'):
- println("You can get it by running 'sudo pip install mock'.")
- elif stem.util.system.is_available('apt-get'):
- println("You can get it by running 'sudo apt-get install python-mock'.")
-
- sys.exit(1)
-
test.task.run(
'INITIALISING',
test.task.STEM_VERSION,
@@ -215,7 +201,6 @@ def main():
test.task.PYTHON_VERSION,
test.task.PLATFORM_VERSION,
test.task.CRYPTO_VERSION,
- test.task.MOCK_VERSION,
test.task.PYFLAKES_VERSION,
test.task.PYCODESTYLE_VERSION,
test.task.CLEAN_PYC,
Index: stem-1.8.0/stem/prereq.py
===================================================================
--- stem-1.8.0.orig/stem/prereq.py
+++ stem-1.8.0/stem/prereq.py
@@ -17,7 +17,6 @@ stem will still read descriptors - just
is_crypto_available - checks if the cryptography module is available
is_zstd_available - checks if the zstd module is available
is_lzma_available - checks if the lzma module is available
- is_mock_available - checks if the mock module is available
"""
import functools
@@ -207,48 +206,6 @@ def is_lzma_available():
return False
-def is_mock_available():
- """
- Checks if the mock module is available. In python 3.3 and up it is a builtin
- unittest module, but before this it needed to be `installed separately
- <https://pypi.org/project/mock/>`_. Imports should be as follows....
-
- ::
-
- try:
- # added in python 3.3
- from unittest.mock import Mock
- except ImportError:
- from mock import Mock
-
- :returns: **True** if the mock module is available and **False** otherwise
- """
-
- try:
- # checks for python 3.3 version
- import unittest.mock
- return True
- except ImportError:
- pass
-
- try:
- import mock
-
- # check for mock's patch.dict() which was introduced in version 0.7.0
-
- if not hasattr(mock.patch, 'dict'):
- raise ImportError()
-
- # check for mock's new_callable argument for patch() which was introduced in version 0.8.0
-
- if 'new_callable' not in inspect.getargspec(mock.patch).args:
- raise ImportError()
-
- return True
- except ImportError:
- return False
-
-
def _is_lru_cache_available():
"""
Functools added lru_cache to the standard library in Python 3.2. Prior to
Index: stem-1.8.0/test/integ/connection/connect.py
===================================================================
--- stem-1.8.0.orig/test/integ/connection/connect.py
+++ stem-1.8.0/test/integ/connection/connect.py
@@ -8,17 +8,13 @@ import stem.connection
import test.require
import test.runner
+from unittest.mock import patch
+
try:
from StringIO import StringIO
except ImportError:
from io import StringIO
-try:
- # added in python 3.3
- from unittest.mock import patch
-except ImportError:
- from mock import patch
-
class TestConnect(unittest.TestCase):
@test.require.controller
Index: stem-1.8.0/test/integ/process.py
===================================================================
--- stem-1.8.0.orig/test/integ/process.py
+++ stem-1.8.0/test/integ/process.py
@@ -28,13 +28,9 @@ import test
import test.require
from contextlib import contextmanager
-from stem.util.test_tools import asynchronous, assert_equal, assert_in, skip
+from unittest.mock import patch, Mock
-try:
- # added in python 3.3
- from unittest.mock import patch, Mock
-except ImportError:
- from mock import patch, Mock
+from stem.util.test_tools import asynchronous, assert_equal, assert_in, skip
BASIC_RELAY_TORRC = """\
SocksPort 9089
Index: stem-1.8.0/test/integ/response/protocolinfo.py
===================================================================
--- stem-1.8.0.orig/test/integ/response/protocolinfo.py
+++ stem-1.8.0/test/integ/response/protocolinfo.py
@@ -14,11 +14,7 @@ import test.integ.util.system
import test.require
import test.runner
-try:
- # added in python 3.3
- from unittest.mock import Mock, patch
-except ImportError:
- from mock import Mock, patch
+from unittest.mock import Mock, patch
class TestProtocolInfo(unittest.TestCase):
Index: stem-1.8.0/test/integ/util/system.py
===================================================================
--- stem-1.8.0.orig/test/integ/util/system.py
+++ stem-1.8.0/test/integ/util/system.py
@@ -14,13 +14,9 @@ import stem.util.system
import test.require
import test.runner
-from stem.util.system import State, DaemonTask
+from unittest.mock import Mock, patch
-try:
- # added in python 3.3
- from unittest.mock import Mock, patch
-except ImportError:
- from mock import Mock, patch
+from stem.util.system import State, DaemonTask
def filter_system_call(prefixes):
Index: stem-1.8.0/test/task.py
===================================================================
--- stem-1.8.0.orig/test/task.py
+++ stem-1.8.0/test/task.py
@@ -14,7 +14,6 @@
|- PYTHON_VERSION - checks our python version
|- PLATFORM_VERSION - checks our operating system version
|- CRYPTO_VERSION - checks our version of cryptography
- |- MOCK_VERSION - checks our version of mock
|- PYFLAKES_VERSION - checks our version of pyflakes
|- PYCODESTYLE_VERSION - checks our version of pycodestyle
|- CLEAN_PYC - removes any *.pyc without a corresponding *.py
@@ -333,7 +332,6 @@ TOR_VERSION = Task('tor version', _check
PYTHON_VERSION = Task('python version', _check_python_version)
PLATFORM_VERSION = Task('operating system', _check_platform_version)
CRYPTO_VERSION = ModuleVersion('cryptography version', 'cryptography', stem.prereq.is_crypto_available)
-MOCK_VERSION = ModuleVersion('mock version', ['unittest.mock', 'mock'], stem.prereq.is_mock_available)
PYFLAKES_VERSION = ModuleVersion('pyflakes version', 'pyflakes')
PYCODESTYLE_VERSION = ModuleVersion('pycodestyle version', ['pycodestyle', 'pep8'])
CLEAN_PYC = Task('checking for orphaned .pyc files', _clean_orphaned_pyc, (SRC_PATHS,), print_runtime = True)
Index: stem-1.8.0/test/unit/connection/authentication.py
===================================================================
--- stem-1.8.0.orig/test/unit/connection/authentication.py
+++ stem-1.8.0/test/unit/connection/authentication.py
@@ -14,15 +14,11 @@ import unittest
import stem.connection
import test
+from unittest.mock import Mock, patch
+
from stem.response import ControlMessage
from stem.util import log
-try:
- # added in python 3.3
- from unittest.mock import Mock, patch
-except ImportError:
- from mock import Mock, patch
-
class TestAuthenticate(unittest.TestCase):
@patch('stem.connection.get_protocolinfo')
Index: stem-1.8.0/test/unit/connection/connect.py
===================================================================
--- stem-1.8.0.orig/test/unit/connection/connect.py
+++ stem-1.8.0/test/unit/connection/connect.py
@@ -4,20 +4,17 @@ Unit tests for the stem.connection.conne
import unittest
+import stem
+import stem.connection
+import stem.socket
+
+from unittest.mock import Mock, patch
+
try:
from StringIO import StringIO
except ImportError:
from io import StringIO
-try:
- from mock import Mock, patch
-except ImportError:
- from unittest.mock import Mock, patch
-
-import stem
-import stem.connection
-import stem.socket
-
class TestConnect(unittest.TestCase):
@patch('sys.stdout', new_callable = StringIO)
Index: stem-1.8.0/test/unit/control/controller.py
===================================================================
--- stem-1.8.0.orig/test/unit/control/controller.py
+++ stem-1.8.0/test/unit/control/controller.py
@@ -14,17 +14,13 @@ import stem.socket
import stem.util.system
import stem.version
+from unittest.mock import Mock, patch
+
from stem import ControllerError, DescriptorUnavailable, InvalidArguments, InvalidRequest, ProtocolError, UnsatisfiableRequest
from stem.control import MALFORMED_EVENTS, _parse_circ_path, Listener, Controller, EventType
from stem.response import ControlMessage
from stem.exit_policy import ExitPolicy
-try:
- # added in python 3.3
- from unittest.mock import Mock, patch
-except ImportError:
- from mock import Mock, patch
-
NS_DESC = 'r %s %s u5lTXJKGsLKufRLnSyVqT7TdGYw 2012-12-30 22:02:49 77.223.43.54 9001 0\ns Fast Named Running Stable Valid\nw Bandwidth=75'
TEST_TIMESTAMP = 12345
Index: stem-1.8.0/test/unit/descriptor/bandwidth_file.py
===================================================================
--- stem-1.8.0.orig/test/unit/descriptor/bandwidth_file.py
+++ stem-1.8.0/test/unit/descriptor/bandwidth_file.py
@@ -4,6 +4,7 @@ Unit tests for stem.descriptor.bandwidth
import datetime
import unittest
+from unittest.mock import Mock, patch
import stem.descriptor
@@ -16,12 +17,6 @@ try:
except ImportError:
from stem.util.ordereddict import OrderedDict
-try:
- # added in python 3.3
- from unittest.mock import Mock, patch
-except ImportError:
- from mock import Mock, patch
-
EXPECTED_MEASUREMENT_1 = {
'scanner': '/scanner.1/scan-data/bws-0.0:0.8-done-2019-01-13-22:55:22',
'measured_at': '1547441722',
Index: stem-1.8.0/test/unit/descriptor/collector.py
===================================================================
--- stem-1.8.0.orig/test/unit/descriptor/collector.py
+++ stem-1.8.0/test/unit/descriptor/collector.py
@@ -5,6 +5,7 @@ Unit tests for stem.descriptor.collector
import datetime
import io
import unittest
+from unittest.mock import Mock, patch
import stem.prereq
@@ -13,12 +14,6 @@ from stem.descriptor.collector import Co
from test.unit.descriptor import get_resource
from test.unit.descriptor.data.collector.index import EXAMPLE_INDEX
-try:
- # added in python 3.3
- from unittest.mock import Mock, patch
-except ImportError:
- from mock import Mock, patch
-
URL_OPEN = 'urllib.request.urlopen' if stem.prereq.is_python_3() else 'urllib2.urlopen'
Index: stem-1.8.0/test/unit/descriptor/hidden_service_v3.py
===================================================================
--- stem-1.8.0.orig/test/unit/descriptor/hidden_service_v3.py
+++ stem-1.8.0/test/unit/descriptor/hidden_service_v3.py
@@ -13,6 +13,8 @@ import stem.prereq
import test.require
+from unittest.mock import patch, Mock
+
from stem.descriptor.hidden_service import (
IntroductionPointV3,
HiddenServiceDescriptorV3,
@@ -33,12 +35,6 @@ try:
except ImportError:
from stem.util.ordereddict import OrderedDict
-try:
- # added in python 3.3
- from unittest.mock import patch, Mock
-except ImportError:
- from mock import patch, Mock
-
require_sha3 = test.require.needs(stem.prereq._is_sha3_available, 'requires sha3')
require_x25519 = test.require.needs(lambda: stem.descriptor.hidden_service.X25519_AVAILABLE, 'requires openssl x5509')
Index: stem-1.8.0/test/unit/descriptor/reader.py
===================================================================
--- stem-1.8.0.orig/test/unit/descriptor/reader.py
+++ stem-1.8.0/test/unit/descriptor/reader.py
@@ -19,11 +19,7 @@ import stem.util.system
import test.unit.descriptor
-try:
- # added in python 3.3
- from unittest.mock import patch
-except ImportError:
- from mock import patch
+from unittest.mock import patch
BASIC_LISTING = """
/tmp 123
Index: stem-1.8.0/test/unit/descriptor/remote.py
===================================================================
--- stem-1.8.0.orig/test/unit/descriptor/remote.py
+++ stem-1.8.0/test/unit/descriptor/remote.py
@@ -13,6 +13,8 @@ import stem.descriptor.remote
import stem.prereq
import stem.util.str_tools
+from unittest.mock import patch, Mock, MagicMock
+
from stem.descriptor.remote import Compression
from test.unit.descriptor import read_resource
@@ -21,12 +23,6 @@ try:
except ImportError:
from httplib import HTTPMessage # python2
-try:
- # added in python 3.3
- from unittest.mock import patch, Mock, MagicMock
-except ImportError:
- from mock import patch, Mock, MagicMock
-
# The urlopen() method is in a different location depending on if we're using
# python 2.x or 3.x. The 2to3 converter accounts for this in imports, but not
# mock annotations.
Index: stem-1.8.0/test/unit/descriptor/server_descriptor.py
===================================================================
--- stem-1.8.0.orig/test/unit/descriptor/server_descriptor.py
+++ stem-1.8.0/test/unit/descriptor/server_descriptor.py
@@ -20,6 +20,8 @@ import stem.version
import stem.util.str_tools
import test.require
+from unittest.mock import Mock, patch
+
from stem.client.datatype import CertType
from stem.descriptor import DigestHash, DigestEncoding
from stem.descriptor.certificate import ExtensionType
@@ -37,12 +39,6 @@ try:
except ImportError:
from stem.util.ordereddict import OrderedDict
-try:
- # added in python 3.3
- from unittest.mock import Mock, patch
-except ImportError:
- from mock import Mock, patch
-
TARFILE_FINGERPRINTS = set([
'B6D83EC2D9E18B0A7A33428F8CFA9C536769E209',
'E0BD57A11F00041A9789577C53A1B784473669E4',
Index: stem-1.8.0/test/unit/directory/authority.py
===================================================================
--- stem-1.8.0.orig/test/unit/directory/authority.py
+++ stem-1.8.0/test/unit/directory/authority.py
@@ -9,11 +9,7 @@ import stem
import stem.directory
import stem.prereq
-try:
- # added in python 3.3
- from unittest.mock import patch, Mock
-except ImportError:
- from mock import patch, Mock
+from unittest.mock import patch, Mock
URL_OPEN = 'urllib.request.urlopen' if stem.prereq.is_python_3() else 'urllib2.urlopen'
Index: stem-1.8.0/test/unit/directory/fallback.py
===================================================================
--- stem-1.8.0.orig/test/unit/directory/fallback.py
+++ stem-1.8.0/test/unit/directory/fallback.py
@@ -17,11 +17,7 @@ try:
except ImportError:
from stem.util.ordereddict import OrderedDict
-try:
- # added in python 3.3
- from unittest.mock import patch, Mock
-except ImportError:
- from mock import patch, Mock
+from unittest.mock import patch, Mock
URL_OPEN = 'urllib.request.urlopen' if stem.prereq.is_python_3() else 'urllib2.urlopen'
Index: stem-1.8.0/test/unit/doctest.py
===================================================================
--- stem-1.8.0.orig/test/unit/doctest.py
+++ stem-1.8.0/test/unit/doctest.py
@@ -15,13 +15,9 @@ import stem.util.system
import stem.version
import test
-from stem.response import ControlMessage
+from unittest.mock import Mock, patch
-try:
- # added in python 3.3
- from unittest.mock import Mock, patch
-except ImportError:
- from mock import Mock, patch
+from stem.response import ControlMessage
EXPECTED_CIRCUIT_STATUS = """\
20 EXTENDED $718BCEA286B531757ACAFF93AE04910EA73DE617=KsmoinOK,$649F2D0ACF418F7CFC6539AB2257EB2D5297BAFA=Eskimo BUILD_FLAGS=NEED_CAPACITY PURPOSE=GENERAL TIME_CREATED=2012-12-06T13:51:11.433755
Index: stem-1.8.0/test/unit/exit_policy/policy.py
===================================================================
--- stem-1.8.0.orig/test/unit/exit_policy/policy.py
+++ stem-1.8.0/test/unit/exit_policy/policy.py
@@ -5,11 +5,7 @@ Unit tests for the stem.exit_policy.Exit
import pickle
import unittest
-try:
- # added in python 3.3
- from unittest.mock import Mock, patch
-except ImportError:
- from mock import Mock, patch
+from unittest.mock import Mock, patch
from stem.exit_policy import (
DEFAULT_POLICY_RULES,
Index: stem-1.8.0/test/unit/interpreter/__init__.py
===================================================================
--- stem-1.8.0.orig/test/unit/interpreter/__init__.py
+++ stem-1.8.0/test/unit/interpreter/__init__.py
@@ -9,11 +9,7 @@ __all__ = [
'help',
]
-try:
- # added in python 3.3
- from unittest.mock import Mock
-except ImportError:
- from mock import Mock
+from unittest.mock import Mock
GETINFO_NAMES = """
info/names -- List of GETINFO options, types, and documentation.
Index: stem-1.8.0/test/unit/interpreter/autocomplete.py
===================================================================
--- stem-1.8.0.orig/test/unit/interpreter/autocomplete.py
+++ stem-1.8.0/test/unit/interpreter/autocomplete.py
@@ -1,15 +1,10 @@
import unittest
-from stem.interpreter.autocomplete import _get_commands, Autocompleter
+from unittest.mock import Mock
+from stem.interpreter.autocomplete import _get_commands, Autocompleter
from test.unit.interpreter import CONTROLLER
-try:
- # added in python 3.3
- from unittest.mock import Mock
-except ImportError:
- from mock import Mock
-
class TestAutocompletion(unittest.TestCase):
def test_autocomplete_results_from_config(self):
Index: stem-1.8.0/test/unit/interpreter/commands.py
===================================================================
--- stem-1.8.0.orig/test/unit/interpreter/commands.py
+++ stem-1.8.0/test/unit/interpreter/commands.py
@@ -5,16 +5,12 @@ import stem
import stem.response
import stem.version
+from unittest.mock import Mock, patch
+
from stem.interpreter.commands import ControlInterpreter, _get_fingerprint
from stem.response import ControlMessage
from test.unit.interpreter import CONTROLLER
-try:
- # added in python 3.3
- from unittest.mock import Mock, patch
-except ImportError:
- from mock import Mock, patch
-
EXPECTED_EVENTS_RESPONSE = """\
\x1b[34mBW 15 25\x1b[0m
\x1b[34mBW 758 570\x1b[0m
Index: stem-1.8.0/test/unit/manual.py
===================================================================
--- stem-1.8.0.orig/test/unit/manual.py
+++ stem-1.8.0/test/unit/manual.py
@@ -13,6 +13,8 @@ import stem.manual
import stem.util.system
import test.require
+from unittest.mock import Mock, patch
+
try:
# account for urllib's change between python 2.x and 3.x
import urllib.request as urllib
@@ -20,12 +22,6 @@ except ImportError:
import urllib2 as urllib
try:
- # added in python 3.3
- from unittest.mock import Mock, patch
-except ImportError:
- from mock import Mock, patch
-
-try:
# added in python 2.7
from collections import OrderedDict
except ImportError:
Index: stem-1.8.0/test/unit/response/events.py
===================================================================
--- stem-1.8.0.orig/test/unit/response/events.py
+++ stem-1.8.0/test/unit/response/events.py
@@ -10,16 +10,12 @@ import stem.response
import stem.response.events
import stem.util.log
+from unittest.mock import Mock
+
from stem import * # enums and exceptions
from stem.response import ControlMessage
from stem.descriptor.router_status_entry import RouterStatusEntryV3
-try:
- # added in python 3.3
- from unittest.mock import Mock
-except ImportError:
- from mock import Mock
-
# ADDRMAP event
ADDRMAP = '650 ADDRMAP www.atagar.com 75.119.206.243 "2012-11-19 00:50:13" \
Index: stem-1.8.0/test/unit/response/protocolinfo.py
===================================================================
--- stem-1.8.0.orig/test/unit/response/protocolinfo.py
+++ stem-1.8.0/test/unit/response/protocolinfo.py
@@ -11,15 +11,11 @@ import stem.util.proc
import stem.util.system
import stem.version
+from unittest.mock import Mock, patch
+
from stem.response import ControlMessage
from stem.response.protocolinfo import AuthMethod
-try:
- # added in python 3.3
- from unittest.mock import Mock, patch
-except ImportError:
- from mock import Mock, patch
-
NO_AUTH = """250-PROTOCOLINFO 1
250-AUTH METHODS=NULL
250-VERSION Tor="0.2.1.30"
Index: stem-1.8.0/test/unit/tutorial.py
===================================================================
--- stem-1.8.0.orig/test/unit/tutorial.py
+++ stem-1.8.0/test/unit/tutorial.py
@@ -7,6 +7,8 @@ import unittest
import stem.descriptor.remote
+from unittest.mock import Mock, patch
+
from stem.control import Controller
from stem.descriptor.router_status_entry import RouterStatusEntryV2, RouterStatusEntryV3
from stem.descriptor.networkstatus import NetworkStatusDocumentV3
@@ -19,12 +21,6 @@ try:
except ImportError:
from io import StringIO
-try:
- # added in python 3.3
- from unittest.mock import Mock, patch
-except ImportError:
- from mock import Mock, patch
-
OVER_THE_RIVER_OUTPUT = """\
* Connecting to tor
Index: stem-1.8.0/test/unit/tutorial_examples.py
===================================================================
--- stem-1.8.0.orig/test/unit/tutorial_examples.py
+++ stem-1.8.0/test/unit/tutorial_examples.py
@@ -15,6 +15,8 @@ import stem.response
import stem.descriptor.remote
import stem.prereq
+from unittest.mock import Mock, patch
+
from stem.control import Controller
from stem.descriptor.networkstatus import NetworkStatusDocumentV3
from stem.descriptor.router_status_entry import RouterStatusEntryV3
@@ -24,12 +26,6 @@ from stem.response import ControlMessage
from test.unit import exec_documentation_example
-try:
- # added in python 3.3
- from unittest.mock import Mock, patch
-except ImportError:
- from mock import Mock, patch
-
OPEN_FUNCTION = open # make a reference so mocking open() won't mess with us
CIRC_CONTENT = '650 CIRC %d %s \
Index: stem-1.8.0/test/unit/util/connection.py
===================================================================
--- stem-1.8.0.orig/test/unit/util/connection.py
+++ stem-1.8.0/test/unit/util/connection.py
@@ -9,6 +9,8 @@ import unittest
import stem
import stem.util.connection
+from unittest.mock import Mock, patch
+
from stem.util.connection import Resolver, Connection
try:
@@ -17,12 +19,6 @@ try:
except ImportError:
import urllib2 as urllib
-try:
- # added in python 3.3
- from unittest.mock import Mock, patch
-except ImportError:
- from mock import Mock, patch
-
URL_OPEN = 'urllib.request.urlopen' if stem.prereq.is_python_3() else 'urllib2.urlopen'
URL = 'https://example.unit.test.url'
Index: stem-1.8.0/test/unit/util/proc.py
===================================================================
--- stem-1.8.0.orig/test/unit/util/proc.py
+++ stem-1.8.0/test/unit/util/proc.py
@@ -7,14 +7,11 @@ import unittest
import test
+from unittest.mock import Mock, patch
+
from stem.util import proc
from stem.util.connection import Connection
-try:
- from unittest.mock import Mock, patch
-except ImportError:
- from mock import Mock, patch
-
TITLE_LINE = b'sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout'
TCP6_CONTENT = b"""\
Index: stem-1.8.0/test/unit/util/system.py
===================================================================
--- stem-1.8.0.orig/test/unit/util/system.py
+++ stem-1.8.0/test/unit/util/system.py
@@ -14,13 +14,9 @@ import unittest
import stem.prereq
-from stem.util import system
+from unittest.mock import Mock, patch
-try:
- # added in python 3.3
- from unittest.mock import Mock, patch
-except ImportError:
- from mock import Mock, patch
+from stem.util import system
# Base responses for the pid_by_name tests. The 'success' and
# 'multiple_results' entries are filled in by tests.
Index: stem-1.8.0/test/unit/version.py
===================================================================
--- stem-1.8.0.orig/test/unit/version.py
+++ stem-1.8.0/test/unit/version.py
@@ -7,13 +7,9 @@ import unittest
import stem.util.system
import stem.version
-from stem.version import Version
+from unittest.mock import Mock, patch
-try:
- # added in python 3.3
- from unittest.mock import Mock, patch
-except ImportError:
- from mock import Mock, patch
+from stem.version import Version
VERSION_CMD_OUTPUT = """Mar 22 23:09:37.088 [notice] Tor v0.2.2.35 \
(git-73ff13ab3cc9570d). This is experimental software. Do not rely on it for \

38
python-cepa.changes Normal file
View File

@@ -0,0 +1,38 @@
-------------------------------------------------------------------
Thu Dec 5 05:09:33 UTC 2024 - Steve Kowalik <steven.kowalik@suse.com>
- Add patch fix-assertions.patch:
* Use correct assertion functions.
- Stop skipping Python 3.12.
-------------------------------------------------------------------
Sun Jan 28 16:46:07 UTC 2024 - Ben Greiner <code@bnavigator.de>
- Enable SLE15 python module for onionshare with Python 3.11
- Use PEP517, don't catchall the sitelib
- Update requirements:
* setuptools is not used at runtime
* cryptography is not required, but recommended
-------------------------------------------------------------------
Wed Mar 8 04:31:43 UTC 2023 - Steve Kowalik <steven.kowalik@suse.com>
- Add patch use-fullargspec.patch:
- Stop using a function that was removed in Python 3.11.
-------------------------------------------------------------------
Thu Oct 27 22:11:38 UTC 2022 - Yogalakshmi Arunachalam <yarunachalam@suse.com>
- Update to v1.8.4
Complete changelog https://stem.torproject.org/change_log.html#version-1-8
-------------------------------------------------------------------
Wed Mar 16 20:59:30 UTC 2022 - Axel Braun <axel.braun@gmx.de>
- Provides/Obsoletes added to avoid python-stem conflict
-------------------------------------------------------------------
Thu Feb 24 20:49:34 UTC 2022 - Ferdinand Thiessen <rpm@fthiessen.de>
- Create package on version 1.8.3, based on python-stem 1.8.0
- Use mock.patch from python-stem

89
python-cepa.spec Normal file
View File

@@ -0,0 +1,89 @@
#
# spec file for package python-cepa
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%{?sle15_python_module_pythons}
Name: python-cepa
Version: 1.8.4
Release: 0
Summary: Python controller library for Tor
License: LGPL-3.0-only
URL: https://github.com/onionshare/cepa
Source: https://files.pythonhosted.org/packages/source/c/cepa/cepa-%{version}.tar.gz
# PATCH-FIX-UPSTREAM mock.patch gh#onionshare/cepa#1 mcepl@suse.com
# Replace use of the external mock module with the one in stdlib.
Patch0: mock.patch
Patch1: use-fullargspec.patch
Patch2: fix-assertions.patch
BuildRequires: %{python_module pip}
BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module wheel}
BuildRequires: %{pythons}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
# SECTION test
BuildRequires: %{python_module pyflakes}
BuildRequires: %{python_module cryptography}
BuildRequires: %{python_module pycodestyle}
# /SECTION
Requires(post): update-alternatives
Requires(postun): update-alternatives
BuildArch: noarch
Recommends: python-cryptography
Provides: python-stem = %version-%release
Obsoletes: python-stem < %version-%release
%python_subpackages
%description
Cepa is a fork of stem that adds support for v3 onion client authentication.
Stem is a Python controller library for Tor.
With it you can use Tor's control protocol to script against the Tor process, or build things such as Nyx.
%prep
%autosetup -p1 -n cepa-%{version}
sed -i '/"setuptools >= 65.4.1"/d' setup.py
%build
%pyproject_wheel
%install
%pyproject_install
%python_clone -a %{buildroot}%{_bindir}/tor-prompt
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%check
export PYTHONDONTWRITEBYTECODE=1
%{python_expand export PYTHONPATH=%{buildroot}%{$python_sitelib}
$python run_tests.py -u
}
%post
%python_install_alternative tor-prompt
%postun
%python_uninstall_alternative tor-prompt
%files %{python_files}
%doc README.md
%license LICENSE
%python_alternative %{_bindir}/tor-prompt
%{python_sitelib}/stem
%{python_sitelib}/cepa-%{version}.dist-info
%changelog

26
use-fullargspec.patch Normal file
View File

@@ -0,0 +1,26 @@
Index: cepa-1.8.4/stem/control.py
===================================================================
--- cepa-1.8.4.orig/stem/control.py
+++ cepa-1.8.4/stem/control.py
@@ -474,7 +474,7 @@ def with_default(yields = False):
def decorator(func):
def get_default(func, args, kwargs):
- arg_names = inspect.getargspec(func).args[1:] # drop 'self'
+ arg_names = inspect.getfullargspec(func).args[1:] # drop 'self'
default_position = arg_names.index('default') if 'default' in arg_names else None
if default_position is not None and default_position < len(args):
Index: cepa-1.8.4/stem/util/conf.py
===================================================================
--- cepa-1.8.4.orig/stem/util/conf.py
+++ cepa-1.8.4/stem/util/conf.py
@@ -285,7 +285,7 @@ def uses_settings(handle, path, lazy_loa
config.load(path)
config._settings_loaded = True
- if 'config' in inspect.getargspec(func).args:
+ if 'config' in inspect.getfullargspec(func).args:
return func(*args, config = config, **kwargs)
else:
return func(*args, **kwargs)