-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setting up the program structure for unit testing
- Loading branch information
Showing
7 changed files
with
50 additions
and
2 deletions.
There are no files selected for viewing
File renamed without changes.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class Foo: | ||
|
||
def __init__(self, x): | ||
assert type(x) is int | ||
self.x = x | ||
|
||
def is_positive(self): | ||
return self.x > 0 | ||
|
||
def get_tens(self): | ||
return self.x % 10 | ||
|
||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import pytest | ||
from linkages.src.example import Foo | ||
|
||
def test_create(): | ||
foo = Foo(10) | ||
assert foo.x == 10 | ||
|
||
try: | ||
Foo('a') | ||
assert False | ||
except AssertionError: | ||
pass | ||
|
||
def test_positive(): | ||
pos = Foo(10) | ||
zero = Foo(0) | ||
neg = Foo(-10) | ||
|
||
assert pos.is_positive() | ||
assert not zero.is_positive() | ||
assert not neg.is_positive() | ||
|
||
def test_tens(): | ||
a = Foo(0) | ||
|
||
for i in range(1000): | ||
a.x = i | ||
assert a.x % 10 == a.get_tens() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from setuptools import setup | ||
|
||
setup( | ||
name='linkage-tests', | ||
version='0.1', | ||
install_requires=['pytest'], | ||
packages=['linkages'], | ||
package_data={'linkages': ['tests/*', 'tests/**/*']}, | ||
) |
This file was deleted.
Oops, something went wrong.