Skip to content

Commit 0f001e7

Browse files
committed
switch from nose to pytest, coveralls to codecov
1 parent 29ea183 commit 0f001e7

File tree

3 files changed

+23
-20
lines changed

3 files changed

+23
-20
lines changed

.travis.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
language: python
2+
23
python:
3-
- "2.7"
4+
- "3.5"
5+
- "3.6"
6+
47
install:
5-
- pip install coveralls flake8
8+
- pip install codecov flake8 pytest pytest-cov
69

710
script:
8-
- nosetests -v -s --with-coverage *.py
11+
- python -m pytest -v -s --cov=factorial *.py
912
- flake8 *.py
13+
1014
after_success:
11-
- coveralls
15+
- codecov

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ On the example of a simple Python script/function establish
1010
practice of
1111

1212
- interaction with [Git](http://git-scm.com) and [GitHub](http://github.com)
13-
- automated testing using [nose](https://nose.readthedocs.org)
13+
- automated testing using [py.test](https://docs.pytest.org/en/latest/)
1414
- code syntax conventions validation using [flake8](http://bitbucket.org/tarek/flake8)
1515

1616
## Problem to solve
@@ -25,14 +25,14 @@ run.
2525

2626
**Solution**:
2727

28-
1. Write recursive `factorial_recursive` to estimate factorial of an
29-
integer n.
28+
1. Write `factorial` to estimate factorial of an
29+
integer n (could be plain iteration or a recursive call).
3030
See [wikipedia](http://en.wikipedia.org/wiki/Factorial) if not sure
3131
about what factorial is
3232

3333
### "Extra credit"
3434

35-
2. Write non-recursive version of a `factorial` function
35+
2. Write both recursive and non-recursive version of a `factorial` function
3636

3737
3. Investigate difference (well - ratio) in time of execution between
3838
the two. Use `time` module to track time.
@@ -45,7 +45,7 @@ run.
4545

4646
- In the terminal now run
4747

48-
git clone https://github.com/YOURLOGIN/psyc161-hw1
48+
git clone https://github.com/YOURLOGIN/psyc161-hw-factorial
4949

5050
to "clone" your remote fork/clone to your local drive
5151

@@ -54,13 +54,13 @@ run.
5454
- You are welcome to use any editor to edit the file, but we recommend
5555
starting to work with [PyCharm](https://www.jetbrains.com/pycharm)
5656

57-
- Function `factorial_recursive` definition provides a skeleton for
57+
- Function `factorial` definition provides a skeleton for
5858
you to fill in (docstring + implementation)
5959

6060
- Test `test_factorial()` implements basic checks already which you
6161
need to expand to degree you feel necessary to state with assurance
6262
that your implementation. You can run all `tests_` present in the
63-
file using `nosetests -s -v factorial.py` (run `man nosetests` in a
63+
file using `python -m pytest -s -v factorial.py` (run `man pytest` in a
6464
terminal to check what options -s and -v are for. Do you need them
6565
both really ATM?)
6666

@@ -74,7 +74,7 @@ be done multiple times
7474
- Whenever you are ready to submit your homework, run `git push` to
7575
push your changes back to **your** clone on GitHub
7676

77-
- Visit your GitHub page (http://github.com/YOURLOGIN/psyc161-hw1) and
77+
- Visit your GitHub page (http://github.com/YOURLOGIN/psyc161-hw-factorial) and
7878
find your changes being present among Commits, and "Send a pull
7979
request" option present.
8080

@@ -83,7 +83,7 @@ be done multiple times
8383

8484
- Review status of the pull request in a few minutes -- it should
8585
report successful pass through travis CI run which runs again
86-
nosetests and flake8 on my behalf. If not -- inspect travis's logs,
86+
pytest and flake8 on my behalf. If not -- inspect travis's logs,
8787
commit fixes locally, push them to github again so that PR gets
8888
updated, and travis gets another run.
8989

factorial.py

100644100755
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
1+
#!/usr/bin/env python
12
"""Module for estimation of factorial (Homework #1)
23
34
Note: this is just a skeleton for you to work with. But it already
45
has some "bugs" you need to catch and fix.
56
"""
67

7-
from nose.tools import assert_equal
88

9-
def factorial_recursive(n):
9+
def factorial(n):
1010
# TODO Define your logic for factorial here
11-
pass # does nothing
11+
return # TODO!
1212

1313
def test_factorial():
14-
assert_equal(factorial_recursive(1), 1)
14+
assert factorial(1) == 1
1515
# TODO: add more
1616

1717
if __name__ == '__main__':
1818
# This is a way to determine either file was "executed", so if it was
19-
# imported (by e.g. nose) as a library, we should not run code
19+
# imported (by e.g. pytest) as a library, we should not run code
2020
# below
21-
2221
nconditions = raw_input("Please enter number of conditions: ")
23-
norders = factorial_recursive(nconditions)
22+
norders = factorial(nconditions)
2423
print("Number of possible trial orders: " + str(norders)

0 commit comments

Comments
 (0)