Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
workspaces
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ssa
workspaces
Commits
24dcfec0
Commit
24dcfec0
authored
4 years ago
by
Nathan Hertz
Browse files
Options
Downloads
Patches
Plain Diff
Changed test naming convention. Added custom fixture for initializing Null object.
parent
639ec67c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
apps/cli/executables/null/test/test_null.py
+11
-12
11 additions, 12 deletions
apps/cli/executables/null/test/test_null.py
with
11 additions
and
12 deletions
apps/cli/executables/null/test/
null_test
.py
→
apps/cli/executables/null/test/
test_null
.py
+
11
−
12
View file @
24dcfec0
import
pytest
import
argparse
from
null.null
import
Null
# from null.null import Null
from
..src.null.null
import
Null
parser
=
argparse
.
ArgumentParser
()
def
test_print_error
(
caplog
):
@pytest.fixture
()
def
null
():
null
=
Null
(
argparse
.
Namespace
(),
True
)
return
null
def
test_print_error
(
null
,
caplog
):
null
.
print_error
()
assert
'
ERROR: This is an error.
'
in
caplog
.
text
def
test_print_greeting
(
caplog
):
null
=
Null
(
argparse
.
Namespace
(),
True
)
def
test_print_greeting
(
null
,
caplog
):
null
.
print_greeting
()
assert
'
Hello, world!
'
in
caplog
.
text
assert
'
And goodbye, world...
'
in
caplog
.
text
def
test_exit_with_failure
(
caplog
):
null
=
Null
(
argparse
.
Namespace
(),
True
)
def
test_exit_with_failure
(
null
,
caplog
):
with
pytest
.
raises
(
SystemExit
)
as
e
:
null
.
exit_with_failure
()
assert
'
Error purposefully induced. Exiting with status code -1...
'
in
caplog
.
text
assert
e
.
value
.
code
==
-
1
def
test_exit_randomly
(
caplog
):
null
=
Null
(
argparse
.
Namespace
(),
True
)
def
test_exit_randomly
(
null
,
caplog
):
with
pytest
.
raises
(
SystemExit
)
as
e
:
null
.
exit_randomly
()
assert
'
Exiting with status code
'
in
caplog
.
text
assert
-
50
<=
e
.
value
.
code
<=
50
def
test_take_nap
(
caplog
):
null
=
Null
(
argparse
.
Namespace
(),
True
)
def
test_take_nap
(
null
,
caplog
):
null
.
take_nap
()
assert
'
Going to sleep...
'
in
caplog
.
text
assert
'
Waking up.
'
in
caplog
.
text
\ No newline at end of file
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