localstack-snapshot 0.3.2__tar.gz → 0.3.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {localstack_snapshot-0.3.2 → localstack_snapshot-0.3.3}/PKG-INFO +1 -1
- localstack_snapshot-0.3.3/localstack_snapshot/__init__.py +1 -0
- {localstack_snapshot-0.3.2 → localstack_snapshot-0.3.3}/localstack_snapshot/snapshots/prototype.py +10 -3
- {localstack_snapshot-0.3.2 → localstack_snapshot-0.3.3}/localstack_snapshot.egg-info/PKG-INFO +1 -1
- {localstack_snapshot-0.3.2 → localstack_snapshot-0.3.3}/pyproject.toml +1 -1
- {localstack_snapshot-0.3.2 → localstack_snapshot-0.3.3}/tests/test_snapshots.py +15 -0
- localstack_snapshot-0.3.2/localstack_snapshot/__init__.py +0 -1
- {localstack_snapshot-0.3.2 → localstack_snapshot-0.3.3}/LICENSE +0 -0
- {localstack_snapshot-0.3.2 → localstack_snapshot-0.3.3}/README.md +0 -0
- {localstack_snapshot-0.3.2 → localstack_snapshot-0.3.3}/localstack_snapshot/pytest/__init__.py +0 -0
- {localstack_snapshot-0.3.2 → localstack_snapshot-0.3.3}/localstack_snapshot/pytest/snapshot.py +0 -0
- {localstack_snapshot-0.3.2 → localstack_snapshot-0.3.3}/localstack_snapshot/snapshots/__init__.py +0 -0
- {localstack_snapshot-0.3.2 → localstack_snapshot-0.3.3}/localstack_snapshot/snapshots/report.py +0 -0
- {localstack_snapshot-0.3.2 → localstack_snapshot-0.3.3}/localstack_snapshot/snapshots/transformer.py +0 -0
- {localstack_snapshot-0.3.2 → localstack_snapshot-0.3.3}/localstack_snapshot/snapshots/transformer_utility.py +0 -0
- {localstack_snapshot-0.3.2 → localstack_snapshot-0.3.3}/localstack_snapshot/util/__init__.py +0 -0
- {localstack_snapshot-0.3.2 → localstack_snapshot-0.3.3}/localstack_snapshot/util/encoding.py +0 -0
- {localstack_snapshot-0.3.2 → localstack_snapshot-0.3.3}/localstack_snapshot.egg-info/SOURCES.txt +0 -0
- {localstack_snapshot-0.3.2 → localstack_snapshot-0.3.3}/localstack_snapshot.egg-info/dependency_links.txt +0 -0
- {localstack_snapshot-0.3.2 → localstack_snapshot-0.3.3}/localstack_snapshot.egg-info/requires.txt +0 -0
- {localstack_snapshot-0.3.2 → localstack_snapshot-0.3.3}/localstack_snapshot.egg-info/top_level.txt +0 -0
- {localstack_snapshot-0.3.2 → localstack_snapshot-0.3.3}/setup.cfg +0 -0
- {localstack_snapshot-0.3.2 → localstack_snapshot-0.3.3}/tests/test_transformer.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.3.3"
|
{localstack_snapshot-0.3.2 → localstack_snapshot-0.3.3}/localstack_snapshot/snapshots/prototype.py
RENAMED
|
@@ -183,14 +183,21 @@ class SnapshotSession:
|
|
|
183
183
|
return obj_.value
|
|
184
184
|
elif hasattr(obj_, "__dict__"):
|
|
185
185
|
# This is an object - let's try to convert it to a dictionary
|
|
186
|
-
# A
|
|
186
|
+
# A naive approach would be to use the '__dict__' object directly, but that only lists the attributes.
|
|
187
187
|
# In order to also serialize the properties, we use the __dir__() method
|
|
188
188
|
# Filtering by everything that is not a method gives us both attributes and properties
|
|
189
|
-
# We also (still) skip private attributes/properties, so everything that starts with an underscore
|
|
189
|
+
# We also (still) skip private attributes/properties, so everything that starts with an underscore.
|
|
190
190
|
return {
|
|
191
191
|
k: _convert_object_to_dict(getattr(obj_, k))
|
|
192
192
|
for k in obj_.__dir__()
|
|
193
|
-
if
|
|
193
|
+
if (
|
|
194
|
+
# Skip private attributes
|
|
195
|
+
not k.startswith("_")
|
|
196
|
+
# Skip everything that's not a method
|
|
197
|
+
and type(getattr(obj_, k, "")).__name__ != "method"
|
|
198
|
+
# Skip everything that refers to itself (identity functions), as that leads to recursion
|
|
199
|
+
and getattr(obj_, k) != obj_
|
|
200
|
+
)
|
|
194
201
|
}
|
|
195
202
|
return obj_
|
|
196
203
|
|
|
@@ -7,7 +7,7 @@ name = "localstack-snapshot"
|
|
|
7
7
|
authors = [
|
|
8
8
|
{ name = "LocalStack Contributors", email = "info@localstack.cloud" }
|
|
9
9
|
]
|
|
10
|
-
version = "0.3.
|
|
10
|
+
version = "0.3.3"
|
|
11
11
|
description = "Extracted snapshot testing lib for LocalStack"
|
|
12
12
|
dependencies = [
|
|
13
13
|
"jsonpath-ng>1.6",
|
|
@@ -137,6 +137,21 @@ class TestSnapshotManager:
|
|
|
137
137
|
sm.match_object("key_a", CustomObject(name="myname"))
|
|
138
138
|
sm._assert_all()
|
|
139
139
|
|
|
140
|
+
def test_match_object_with_identity_function(self):
|
|
141
|
+
class CustomObject:
|
|
142
|
+
def __init__(self, name):
|
|
143
|
+
self.name = name
|
|
144
|
+
|
|
145
|
+
@property
|
|
146
|
+
def me_myself_and_i(self):
|
|
147
|
+
# This would lead to a RecursionError, so we cannot snapshot this method
|
|
148
|
+
return self
|
|
149
|
+
|
|
150
|
+
sm = SnapshotSession(scope_key="A", verify=True, base_file_path="", update=False)
|
|
151
|
+
sm.recorded_state = {"key_a": {"name": "myname"}}
|
|
152
|
+
sm.match_object("key_a", CustomObject(name="myname"))
|
|
153
|
+
sm._assert_all()
|
|
154
|
+
|
|
140
155
|
def test_match_object_change(self):
|
|
141
156
|
class CustomObject:
|
|
142
157
|
def __init__(self, name):
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.3.2"
|
|
File without changes
|
|
File without changes
|
{localstack_snapshot-0.3.2 → localstack_snapshot-0.3.3}/localstack_snapshot/pytest/__init__.py
RENAMED
|
File without changes
|
{localstack_snapshot-0.3.2 → localstack_snapshot-0.3.3}/localstack_snapshot/pytest/snapshot.py
RENAMED
|
File without changes
|
{localstack_snapshot-0.3.2 → localstack_snapshot-0.3.3}/localstack_snapshot/snapshots/__init__.py
RENAMED
|
File without changes
|
{localstack_snapshot-0.3.2 → localstack_snapshot-0.3.3}/localstack_snapshot/snapshots/report.py
RENAMED
|
File without changes
|
{localstack_snapshot-0.3.2 → localstack_snapshot-0.3.3}/localstack_snapshot/snapshots/transformer.py
RENAMED
|
File without changes
|
|
File without changes
|
{localstack_snapshot-0.3.2 → localstack_snapshot-0.3.3}/localstack_snapshot/util/__init__.py
RENAMED
|
File without changes
|
{localstack_snapshot-0.3.2 → localstack_snapshot-0.3.3}/localstack_snapshot/util/encoding.py
RENAMED
|
File without changes
|
{localstack_snapshot-0.3.2 → localstack_snapshot-0.3.3}/localstack_snapshot.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{localstack_snapshot-0.3.2 → localstack_snapshot-0.3.3}/localstack_snapshot.egg-info/requires.txt
RENAMED
|
File without changes
|
{localstack_snapshot-0.3.2 → localstack_snapshot-0.3.3}/localstack_snapshot.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|