Skip to content

Commit

Permalink
Merge pull request #366 from kajinamit/remove-extras
Browse files Browse the repository at this point in the history
Remove dependency on the extras library
  • Loading branch information
mtreinish authored Nov 22, 2024
2 parents cb0a935 + aeebcff commit 1dd16b3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
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

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


def write_list(stream, test_ids):
Expand Down

0 comments on commit 1dd16b3

Please sign in to comment.