Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
silkaj
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
clients
python
silkaj
Commits
33293c8b
Commit
33293c8b
authored
4 years ago
by
matograine
Committed by
matograine
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[test] [fix]
#368
: wrong use of context `with pytest.raises() as...`
* fix wrong tests
parent
bf6cfe37
No related branches found
No related tags found
No related merge requests found
Pipeline
#10859
passed
4 years ago
Stage: checks
Stage: tests
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/test_crypto_tools.py
+4
-4
4 additions, 4 deletions
tests/test_crypto_tools.py
tests/test_unit_tx.py
+3
-4
3 additions, 4 deletions
tests/test_unit_tx.py
with
7 additions
and
8 deletions
tests/test_crypto_tools.py
+
4
−
4
View file @
33293c8b
...
@@ -38,7 +38,7 @@ def test_gen_checksum(pubkey, checksum):
...
@@ -38,7 +38,7 @@ def test_gen_checksum(pubkey, checksum):
(
(
"
J4c8CARmP9vAFNGtHRuzx14zvxojyRWHW2darguVqjtX
"
,
"
J4c8CARmP9vAFNGtHRuzx14zvxojyRWHW2darguVqjtX
"
,
"
KA
"
,
"
KA
"
,
"
Error:
Wrong checksum for following
public key
:
J4c8CARmP9vAFNGtHRuzx14zvxojyRWHW2darguVqjtX
"
,
"
Error: public key
'
J4c8CARmP9vAFNGtHRuzx14zvxojyRWHW2darguVqjtX
'
does not match checksum
'
KA
'
.
\n
Please verify the public key.
\n
"
,
),
),
],
],
)
)
...
@@ -49,7 +49,7 @@ def test_validate_checksum(pubkey, checksum, expected, capsys):
...
@@ -49,7 +49,7 @@ def test_validate_checksum(pubkey, checksum, expected, capsys):
else
:
else
:
with
pytest
.
raises
(
SystemExit
)
as
pytest_exit
:
with
pytest
.
raises
(
SystemExit
)
as
pytest_exit
:
test
=
crypto_tools
.
validate_checksum
(
pubkey_with_ck
)
test
=
crypto_tools
.
validate_checksum
(
pubkey_with_ck
)
assert
capsys
.
readouterr
()
==
expected
assert
capsys
.
readouterr
()
.
out
==
expected
assert
pytest_exit
.
type
==
SystemExit
assert
pytest_exit
.
type
==
SystemExit
...
@@ -60,14 +60,14 @@ def test_validate_checksum(pubkey, checksum, expected, capsys):
...
@@ -60,14 +60,14 @@ def test_validate_checksum(pubkey, checksum, expected, capsys):
(
"
J4c8CARmP9vAFNGtHRuzx14zvxojyRWHW2darguVqjtX:KAv
"
,
True
,
True
),
(
"
J4c8CARmP9vAFNGtHRuzx14zvxojyRWHW2darguVqjtX:KAv
"
,
True
,
True
),
(
"
J4c8CARmP9vAFNGtHRuzx14zvxojyRWHW2darguVqjtX
"
,
True
,
False
),
(
"
J4c8CARmP9vAFNGtHRuzx14zvxojyRWHW2darguVqjtX
"
,
True
,
False
),
(
"
Youpi
"
,
False
,
None
),
(
"
Youpi
"
,
False
,
None
),
(
"
Youpi
"
,
True
,
"
Error: bad format for following public key: Youpi
"
),
(
"
Youpi
"
,
True
,
"
Error: bad format for following public key: Youpi
\n
"
),
],
],
)
)
def
test_check_pubkey_format
(
pubkey
,
display_error
,
expected
,
capsys
):
def
test_check_pubkey_format
(
pubkey
,
display_error
,
expected
,
capsys
):
if
isinstance
(
expected
,
str
):
if
isinstance
(
expected
,
str
):
with
pytest
.
raises
(
SystemExit
)
as
pytest_exit
:
with
pytest
.
raises
(
SystemExit
)
as
pytest_exit
:
test
=
crypto_tools
.
check_pubkey_format
(
pubkey
,
display_error
)
test
=
crypto_tools
.
check_pubkey_format
(
pubkey
,
display_error
)
assert
capsys
.
readouterr
()
==
expected
assert
capsys
.
readouterr
()
.
out
==
expected
assert
pytest_exit
.
type
==
SystemExit
assert
pytest_exit
.
type
==
SystemExit
else
:
else
:
assert
expected
==
crypto_tools
.
check_pubkey_format
(
pubkey
,
display_error
)
assert
expected
==
crypto_tools
.
check_pubkey_format
(
pubkey
,
display_error
)
...
...
This diff is collapsed.
Click to expand it.
tests/test_unit_tx.py
+
3
−
4
View file @
33293c8b
...
@@ -193,7 +193,7 @@ def test_compute_amounts_errors(capsys):
...
@@ -193,7 +193,7 @@ def test_compute_amounts_errors(capsys):
trial
[
1
],
trial
[
1
],
)
)
assert
pytest_exit
.
type
==
SystemExit
assert
pytest_exit
.
type
==
SystemExit
expected_error
=
"
Error: amount {0} is too low.
"
.
format
(
trial
[
0
][
0
])
expected_error
=
"
Error: amount {0} is too low.
\n
"
.
format
(
trial
[
0
][
0
])
assert
capsys
.
readouterr
().
out
==
expected_error
assert
capsys
.
readouterr
().
out
==
expected_error
...
@@ -1347,9 +1347,9 @@ def test_check_transaction_values_errors(
...
@@ -1347,9 +1347,9 @@ def test_check_transaction_values_errors(
assert
pytest_exit
.
type
==
SystemExit
assert
pytest_exit
.
type
==
SystemExit
display
=
capsys
.
readouterr
()
display
=
capsys
.
readouterr
()
if
comment
.
find
(
"
Wrong_Char_
"
)
!=
-
1
:
if
comment
.
find
(
"
Wrong_Char_
"
)
!=
-
1
:
assert
display
==
"
Error: the format of the comment is invalid
"
assert
display
.
out
==
"
Error: the format of the comment is invalid
\n
"
elif
len
(
comment
)
>
tx
.
MAX_COMMENT_LENGTH
:
elif
len
(
comment
)
>
tx
.
MAX_COMMENT_LENGTH
:
assert
display
==
"
Error:
the format of the comment is invalid
"
assert
display
.
out
==
"
Error:
Comment is too long
\n
"
elif
"
Wrong_Pubkey
"
in
outputAddresses
:
elif
"
Wrong_Pubkey
"
in
outputAddresses
:
assert
display
.
out
.
find
(
"
Error: bad format for following public key:
"
)
!=
-
1
assert
display
.
out
.
find
(
"
Error: bad format for following public key:
"
)
!=
-
1
elif
outputBackChange
:
elif
outputBackChange
:
...
@@ -1360,7 +1360,6 @@ def test_check_transaction_values_errors(
...
@@ -1360,7 +1360,6 @@ def test_check_transaction_values_errors(
display
.
out
.
find
(
"
pubkey doesn’t have enough money for this transaction.
"
)
display
.
out
.
find
(
"
pubkey doesn’t have enough money for this transaction.
"
)
!=
-
1
!=
-
1
)
)
assert
result
==
""
# test generate_unlocks()
# test generate_unlocks()
...
...
This diff is collapsed.
Click to expand it.
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