Skip to content

Commit

Permalink
Initial testing setup
Browse files Browse the repository at this point in the history
Setting up the program structure for unit testing
  • Loading branch information
ejbosia committed Sep 2, 2021
1 parent 9c5d2a6 commit d755e7c
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 2 deletions.
File renamed without changes.
Empty file added linkages/src/__init__.py
Empty file.
13 changes: 13 additions & 0 deletions linkages/src/example.py
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 added linkages/tests/__init__.py
Empty file.
28 changes: 28 additions & 0 deletions linkages/tests/test_example.py
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()
9 changes: 9 additions & 0 deletions setup.py
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/**/*']},
)
2 changes: 0 additions & 2 deletions tests/test.py

This file was deleted.

0 comments on commit d755e7c

Please sign in to comment.