Skip to content

Commit

Permalink
Merge branch 'feature-2.0' into 711-finally-block
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelboulton committed Jan 12, 2023
2 parents 3a32a6c + 74643e9 commit 6e87f35
Show file tree
Hide file tree
Showing 14 changed files with 22 additions and 26 deletions.
2 changes: 1 addition & 1 deletion docs/source/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ If you don't need any functionality provided by this, you can define empty
`__enter__` and `__exit__` methods on your class like so:

```python
class MySession(object):
class MySession:

def __enter__(self):
pass
Expand Down
4 changes: 2 additions & 2 deletions tavern/_core/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ class FloatToken(TypeConvertToken):
constructor = float


class StrToBoolConstructor(object):
class StrToBoolConstructor:
"""Using `bool` as a constructor directly will evaluate all strings to `True`."""

def __new__(cls, s):
Expand All @@ -368,7 +368,7 @@ class BoolToken(TypeConvertToken):
constructor = StrToBoolConstructor


class StrToRawConstructor(object):
class StrToRawConstructor:
"""Used when we want to ignore brace formatting syntax"""

def __new__(cls, s):
Expand Down
2 changes: 1 addition & 1 deletion tavern/_core/pytest/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
logger = logging.getLogger(__name__)


class ReprdError(object):
class ReprdError:
def __init__(self, exce, item):
self.exce = exce
self.item = item
Expand Down
2 changes: 1 addition & 1 deletion tavern/_core/pytest/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def __init__(self, *args, **kwargs):
# This (and the FakeObj below) are to make pytest-pspec not error out.
# The 'docstring' for this is the filename, the 'docstring' for each
# individual test is the actual test name.
class FakeObj(object):
class FakeObj:
__doc__ = self.fspath.strpath

self.obj = FakeObj
Expand Down
2 changes: 0 additions & 2 deletions tavern/_core/schema/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
from tavern._core.plugins import load_plugins
from tavern._core.schema.jsonschema import verify_jsonschema

# core.yml.safe_load = functools.partial(yaml.load, Loader=IncludeLoader)

logger = logging.getLogger(__name__)


Expand Down
1 change: 0 additions & 1 deletion tavern/_core/schema/jsonschema.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ def verify_jsonschema(to_verify, schema):
try:
validator.validate(to_verify)
except jsonschema.ValidationError as e:
print(e)
real_context = []

# ignore these strings because they're red herrings
Expand Down
2 changes: 1 addition & 1 deletion tavern/_plugins/mqtt/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def root_topic(topic):


@dataclasses.dataclass
class _Subscription(object):
class _Subscription:
topic: str
subscribed: bool = False

Expand Down
2 changes: 1 addition & 1 deletion tavern/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
logger = logging.getLogger(__name__)


class BaseRequest(object):
class BaseRequest:
@property
@abstractmethod
def request_vars(self):
Expand Down
2 changes: 1 addition & 1 deletion tavern/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def indent_err_text(err):
return indent(err, " " * 4)


class BaseResponse(object):
class BaseResponse:
def __init__(self, name, expected, test_block_config):
self.name = name

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/response/test_mqtt_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def __init__(self, returned):
self.timestamp = 0


class TestResponse(object):
class TestResponse:
@staticmethod
def _get_fake_verifier(expected, fake_messages, includes):
"""Given a list of messages, return a mocked version of the MQTT
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def test_not_called_cli(self, fake_item):

@pytest.fixture(name="nested_response")
def fix_nested_response():
class response_content(object):
class response_content:
content = {
"top": {
"Thing": "value",
Expand Down Expand Up @@ -291,7 +291,7 @@ def test_validate_schema_incorrect(self, nested_response):
)


class TestCheckParseValues(object):
class TestCheckParseValues:
@pytest.mark.parametrize(
"item", [[134], {"a": 2}, yaml, yaml.load, yaml.SafeLoader]
)
Expand All @@ -313,7 +313,7 @@ def test_no_warn_good_type(self, item):
assert not wmock.called


class TestFormatWithJson(object):
class TestFormatWithJson:
@pytest.mark.parametrize(
"item", [[134], {"a": 2}, yaml, yaml.load, yaml.SafeLoader]
)
Expand All @@ -339,7 +339,7 @@ def test_bad_format_string_multiple(self):
format_keys(ForceIncludeToken("{a}{b}"), {"fd": "123"})


class TestCheckFileSpec(object):
class TestCheckFileSpec:
def _wrap_test_block(self, dowith):
validate_file_spec({"files": dowith}, Mock(), Mock())

Expand Down
6 changes: 3 additions & 3 deletions tests/unit/test_mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_host_required():
MQTTClient(**args)


class TestClient(object):
class TestClient:
@pytest.fixture(name="fake_client")
def fix_fake_client(self):
args = {"connect": {"host": "localhost"}}
Expand Down Expand Up @@ -96,7 +96,7 @@ class FakeMessage:
fake_client.publish("abc", "123")


class TestTLS(object):
class TestTLS:
def test_missing_cert_gives_error(self):
"""Missing TLS cert gives an error"""
args = {"certfile": "/lcliueurhug/ropko3kork32"}
Expand Down Expand Up @@ -148,7 +148,7 @@ def test_correct_format(self, req, includes):
MQTTRequest(Mock(), req, includes)


class TestSubscription(object):
class TestSubscription:
@staticmethod
def get_mock_client_with(subcribe_action):
mock_paho = Mock(spec=paho.Client, subscribe=subcribe_action)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_pytest_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def test_none():


@pytest.mark.parametrize("faker", [Faker(), Faker("zh_CN")])
class TestMakeFile(object):
class TestMakeFile:
def test_only_single(self, faker):
marks = [get_basic_parametrize_mark(faker)]

Expand Down
11 changes: 5 additions & 6 deletions tests/unit/test_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def fix_example_request():
return spec.copy()


class TestRequests(object):
class TestRequests:
def test_unknown_fields(self, req, includes):
"""Unkown args should raise an error"""
req["fodokfowe"] = "Hello"
Expand All @@ -64,7 +64,7 @@ def test_bad_get_body(self, req, includes):
)


class TestHttpRedirects(object):
class TestHttpRedirects:
def test_session_called_no_redirects(self, req, includes):
"""Always disable redirects by defauly"""

Expand All @@ -89,7 +89,7 @@ def test_session_do_follow_redirects_based_on_global_flag(
assert _check_allow_redirects(req, includes) == do_follow


class TestCookies(object):
class TestCookies:
@pytest.fixture
def mock_session(self):
return Mock(spec=requests.Session, cookies=RequestsCookieJar())
Expand Down Expand Up @@ -180,7 +180,7 @@ def test_no_duplicate_cookie(self, req, includes):
_read_expected_cookies(mock_session, req, includes)


class TestRequestArgs(object):
class TestRequestArgs:
def test_default_method(self, req, includes):
del req["method"]
del req["data"]
Expand Down Expand Up @@ -366,7 +366,6 @@ def test_file_body_content_type(self, req, includes):
req["file_body"] = tmpin.name

args = get_request_args(req, includes)
print(args)

assert args["file_body"] == tmpin.name
assert args["headers"]["content-type"] == "application/json"
Expand All @@ -391,7 +390,7 @@ def test_file_body_content_encoding(self, req, includes):
assert args["headers"]["Content-Encoding"] == "gzip"


class TestGetFiles(object):
class TestGetFiles:
@pytest.fixture
def mock_stack(self):
return Mock(spec=ExitStack)
Expand Down

0 comments on commit 6e87f35

Please sign in to comment.