diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 00000000..34a1bebf --- /dev/null +++ b/.coveragerc @@ -0,0 +1,9 @@ +# .coveragerc to control coverage + +[run] +branch = True + +source = . + +[html] +directory = htmlcov diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..89437a9d --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.coverage +shippable/ diff --git a/README.md b/README.md index ec522d27..b53f21b5 100755 --- a/README.md +++ b/README.md @@ -2,3 +2,9 @@ Python Sample ===================== Simple Python sample with tests using Nose and Coverage. + +This sample is built for Shippable, a docker based continuous integration and deployment platform. + +[![Run Status](https://rcapi.shippable.com/projects/5809c5873388de0e00d535ed/badge?branch=master)](https://rcapp.shippable.com/github/shiphitchcock1/sample_python) + +[![Coverage Badge](https://rcapi.shippable.com/projects/5809c5873388de0e00d535ed/coverageBadge?branch=master)](https://rcapp.shippable.com/github/shiphitchcock1/sample_python) diff --git a/app.py b/app.py index b3cf7d91..e90893ac 100644 --- a/app.py +++ b/app.py @@ -8,7 +8,33 @@ def calculate(self): def retrieve(self): return self.result +class App2(): + def __init__(self): + self.var2 = 15 + + def calculate(self): + self.result = self.var2 * 4 + + def retrieve(self): + return self.result + +class App3(): + def __init__(self): + self.var3 = 15 + + def calculate(self): + self.result = self.var3 * 5 + + def retrieve(self): + return self.result + if __name__ == "__main__": app = App() app.calculate() print(app.retrieve) + app2 = App2() + app2.calculate() + print(app2.retrieve) + app3 = App3() + app3.calculate() + print(app3.retrieve) diff --git a/app2.py b/app2.py new file mode 100644 index 00000000..a47f74c1 --- /dev/null +++ b/app2.py @@ -0,0 +1,15 @@ +class App2(): + def __init__(self): + self.var2 = 15 + + def calculate(self): + self.result = self.var2 * 4 + 1 + + def retrieve(self): + return self.result + +if __name__ == "__main__": + app = App2() + app.calculate() + print(app.retrieve) + diff --git a/shippable.yml b/shippable.yml index 3bdcdf82..586316de 100755 --- a/shippable.yml +++ b/shippable.yml @@ -1,7 +1,16 @@ language: python +#build_image: shippableimages/ubuntu1204_python python: - - 2.7 + # - 2.6 +# - 2.7 + # - 3.2 + # - 3.3 +# - 3.4 + - 3.5 + - 3.6 + - pypy + #- pypy3 install: - pip install -r requirements.txt @@ -12,6 +21,7 @@ before_script: - mkdir -p shippable/codecoverage script: - - nosetests test.py --with-xunit --xunit-file=shippable/testresults/nosetests.xml - - which python && coverage run --branch test.py - - which python && coverage xml -o shippable/codecoverage/coverage.xml test.py \ No newline at end of file + - which python + - coverage run `which nosetests` test.py --with-xunit --xunit-file=shippable/testresults/nosetests.xml + - coverage xml -o shippable/codecoverage/coverage.xml + diff --git a/test.py b/test.py index e090dee3..6c13eb96 100755 --- a/test.py +++ b/test.py @@ -1,13 +1,29 @@ import unittest from app import App -class TestSuite(unittest.TestCase): +class TestSuite1(unittest.TestCase): def test(self): app = App() app.calculate() self.failIf(app.retrieve() != 62) +from app import App2 + +class TestSuite2(unittest.TestCase): + + def test(self): + app2 = App2() + app2.calculate() + self.failIf(app2.retrieve() != 60) + +from app import App3 + +class TestSuite3(unittest.TestCase): + def test(self): + app3 = App3() + app3.calculate() + self.failIf(app3.retrieve() != 75) def main(): unittest.main() diff --git a/test2.py b/test2.py new file mode 100644 index 00000000..d48dd06a --- /dev/null +++ b/test2.py @@ -0,0 +1,15 @@ +import unittest +from app2 import App2 + +class TestSuite(unittest.TestCase): + + def test(self): + app2 = App2() + app2.calculate() + self.failIf(app2.retrieve() != 61) + +def main(): + unittest.main() + +if __name__ == "__main__": + main()