Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
python_project
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
Container 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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
examples
python_project
Commits
4a7ea4c7
Commit
4a7ea4c7
authored
6 years ago
by
Tamas Gal
Browse files
Options
Downloads
Patches
Plain Diff
Add tests for calculate_mean
parent
e38ec4a4
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
foo/tests/test_bar.py
+19
-1
19 additions, 1 deletion
foo/tests/test_bar.py
with
19 additions
and
1 deletion
foo/tests/test_bar.py
+
19
−
1
View file @
4a7ea4c7
...
...
@@ -3,7 +3,7 @@
# Filename: test_bar.py
from
unittest
import
TestCase
from
foo.bar
import
whats_the_meaning_of_life
from
foo.bar
import
whats_the_meaning_of_life
,
calculate_mean
__author__
=
"
Your Name
"
__credits__
=
[]
...
...
@@ -20,3 +20,21 @@ class TestMeaningOfLife(TestCase):
def
test_meaning_of_life_with_one_core
(
self
):
assert
42
==
whats_the_meaning_of_life
(
n_cores
=
1
)
class
TestCalculateMean
(
TestCase
):
"""
Tests for the calculate_mean function
"""
def
test_calculate_mean_of_a_single_number_returns_the_number_itself
(
self
):
assert
0
==
calculate_mean
([
0
])
assert
1
==
calculate_mean
([
1
])
assert
2
==
calculate_mean
([
2
])
assert
-
1
==
calculate_mean
([
-
1
])
assert
1.5
==
calculate_mean
([
1.5
])
def
test_calculate_mean_returns_mean_of_a_list_of_numbers
(
self
):
assert
2
==
calculate_mean
([
1
,
2
,
3
])
assert
3
==
calculate_mean
([
1
,
2
,
3
,
4
,
5
])
def
test_calculate_mean_returns_correct_value_for_negative_numbers
(
self
):
assert
-
3
==
calculate_mean
([
-
1
,
-
2
,
-
3
,
-
4
,
-
5
])
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