Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
diffoscope
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Reproducible Builds
diffoscope
Commits
e8d5f6a8
Commit
e8d5f6a8
authored
3 years ago
by
Chris Lamb
Browse files
Options
Downloads
Patches
Plain Diff
Fix Python decompilation tests with Python 3.10+. (Closes:
#278
)
parent
d28c2d36
No related branches found
No related tags found
No related merge requests found
Pipeline
#303771
passed
3 years ago
Stage: test
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/comparators/test_python.py
+11
-2
11 additions, 2 deletions
tests/comparators/test_python.py
tests/utils/data.py
+2
-2
2 additions, 2 deletions
tests/utils/data.py
with
13 additions
and
4 deletions
tests/comparators/test_python.py
+
11
−
2
View file @
e8d5f6a8
...
...
@@ -17,6 +17,7 @@
# along with diffoscope. If not, see <https://www.gnu.org/licenses/>.
import
pytest
import
sys
from
diffoscope.comparators.python
import
PycFile
...
...
@@ -33,7 +34,11 @@ def test_identification(pyc1, pyc2):
def
test_no_differences
(
pyc1
):
assert
pyc1
.
compare
(
pyc1
)
is
None
# Disassembling bytecode prior to Python 3.10 is stable when applied to
# itself, otherwise various memory offsets (or memory addresses?) are
# non-deterministic.
if
sys
.
version_info
<
(
3
,
10
):
assert
pyc1
.
compare
(
pyc1
)
is
None
@pytest.fixture
...
...
@@ -42,4 +47,8 @@ def differences(pyc1, pyc2):
def
test_diff
(
differences
):
assert_diff
(
differences
[
0
],
"
pyc_expected_diff
"
)
assert_diff
(
differences
[
0
],
"
pyc_expected_diff
"
,
lambda
haystack
,
needle
:
haystack
.
startswith
(
needle
),
)
This diff is collapsed.
Click to expand it.
tests/utils/data.py
+
2
−
2
View file @
e8d5f6a8
...
...
@@ -56,12 +56,12 @@ def get_data(filename):
return
f
.
read
()
def
assert_diff
(
difference
,
filename
):
def
assert_diff
(
difference
,
filename
,
cmp
=
lambda
x
,
y
:
x
==
y
):
# Assign seen and expected values to local variables to improve contextual
# information in failed tests.
seen
=
difference
.
unified_diff
expected
=
get_data
(
filename
)
assert
seen
==
expected
assert
cmp
(
seen
,
expected
)
# https://code.activestate.com/recipes/576620-changedirectory-context-manager/#c3
...
...
This diff is collapsed.
Click to expand it.
Zbigniew Jędrzejewski-Szmek
@zbyszek-guest
·
3 years ago
Contributor
Thanks, the tests now pass with python3-3.10.0-1.fc35.x86_64.
Thanks, the tests now pass with python3-3.10.0-1.fc35.x86_64.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment