Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dependency on the extras library #366

Merged
merged 3 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ testtools>=2.2.0 # MIT
PyYAML>=3.10.0 # MIT
voluptuous>=0.8.9 # BSD License
tomlkit>=0.11.6 # MIT
extras>=1.0.0
5 changes: 1 addition & 4 deletions stestr/repository/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@

"""In memory storage of test results."""

from extras import try_import

from collections import OrderedDict
from io import BytesIO
from operator import methodcaller

Expand All @@ -22,8 +21,6 @@

from stestr.repository import abstract as repository

OrderedDict = try_import("collections.OrderedDict", dict)


class RepositoryFactory(repository.AbstractRepositoryFactory):
"""A factory that can initialise and open memory repositories.
Expand Down
8 changes: 3 additions & 5 deletions stestr/subunit_runner/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
import sys
import unittest

import extras


def filter_by_ids(suite_or_case, test_ids):
"""Remove tests from suite_or_case where their id is not in test_ids.
Expand Down Expand Up @@ -59,10 +57,10 @@ def filter_by_ids(suite_or_case, test_ids):
than guessing how to reconstruct a new suite.
"""
# Compatible objects
if extras.safe_hasattr(suite_or_case, "filter_by_ids"):
if hasattr(suite_or_case, "filter_by_ids"):
return suite_or_case.filter_by_ids(test_ids)
# TestCase objects.
if extras.safe_hasattr(suite_or_case, "id"):
if hasattr(suite_or_case, "id"):
if suite_or_case.id() in test_ids:
return suite_or_case
else:
Expand Down Expand Up @@ -197,7 +195,7 @@ def __init__(
self.runTests()
else:
runner = self._get_runner()
if extras.safe_hasattr(runner, "list"):
if hasattr(runner, "list"):
try:
runner.list(self.test, loader=self.testLoader)
except TypeError:
Expand Down
13 changes: 9 additions & 4 deletions stestr/testlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@

import io

from extras import try_import

bytestream_to_streamresult = try_import("subunit.ByteStreamToStreamResult")
stream_result = try_import("testtools.testresult.doubles.StreamResult")
try:
from subunit import ByteStreamToStreamResult as bytestream_to_streamresult
except ImportError:
bytestream_to_streamresult = None

Check warning on line 20 in stestr/testlist.py

View check run for this annotation

Codecov / codecov/patch

stestr/testlist.py#L19-L20

Added lines #L19 - L20 were not covered by tests

try:
from testtools.testresult.doubles import StreamResult as stream_result
except ImportError:
stream_result = None

Check warning on line 25 in stestr/testlist.py

View check run for this annotation

Codecov / codecov/patch

stestr/testlist.py#L24-L25

Added lines #L24 - L25 were not covered by tests


def write_list(stream, test_ids):
Expand Down
Loading