mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2025-12-11 20:02:09 +00:00
Added approvals version of python test
This commit is contained in:
parent
69245fd714
commit
58a991fe27
@ -7,7 +7,7 @@ Suggestion: create a python virtual environment for this project. See the [docum
|
||||
## Run the unit tests from the Command-Line
|
||||
|
||||
```
|
||||
python test_gilded_rose.py
|
||||
python tests/test_gilded_rose.py
|
||||
```
|
||||
|
||||
## Run the TextTest fixture from the Command-Line
|
||||
@ -27,3 +27,13 @@ There are instructions in the [TextTest Readme](../texttests/README.md) for sett
|
||||
|
||||
executable:${TEXTTEST_HOME}/python/texttest_fixture.py
|
||||
interpreter:python
|
||||
|
||||
## Run the ApprovalTests.Python test
|
||||
|
||||
This test uses the framework [ApprovalTests.Python](https://github.com/approvals/ApprovalTests.Python). Run it like this:
|
||||
|
||||
```
|
||||
python tests/test_gilded_rose_approvals.py
|
||||
```
|
||||
|
||||
You will need to approve the output file which appears under "approved_files" by renaming it from xxx.received.txt to xxx.approved.txt.
|
||||
|
||||
0
python/tests/__init__.py
Normal file
0
python/tests/__init__.py
Normal file
3
python/tests/approvaltests_config.json
Normal file
3
python/tests/approvaltests_config.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"subdirectory": "approved_files"
|
||||
}
|
||||
0
python/tests/conftest.py
Normal file
0
python/tests/conftest.py
Normal file
21
python/tests/test_gilded_rose_approvals.py
Normal file
21
python/tests/test_gilded_rose_approvals.py
Normal file
@ -0,0 +1,21 @@
|
||||
import io
|
||||
import sys
|
||||
|
||||
from approvaltests import verify
|
||||
from texttest_fixture import main
|
||||
|
||||
def test_gilded_rose_approvals():
|
||||
orig_sysout = sys.stdout
|
||||
try:
|
||||
fake_stdout = io.StringIO()
|
||||
sys.stdout = fake_stdout
|
||||
sys.argv = ["texttest_fixture.py", 30]
|
||||
main()
|
||||
answer = fake_stdout.getvalue()
|
||||
finally:
|
||||
sys.stdout = orig_sysout
|
||||
|
||||
verify(answer)
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_gilded_rose_approvals()
|
||||
@ -3,7 +3,8 @@ from __future__ import print_function
|
||||
|
||||
from gilded_rose import *
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
def main():
|
||||
print("OMGHAI!")
|
||||
items = [
|
||||
Item(name="+5 Dexterity Vest", sell_in=10, quality=20),
|
||||
@ -16,7 +17,6 @@ if __name__ == "__main__":
|
||||
Item(name="Backstage passes to a TAFKAL80ETC concert", sell_in=5, quality=49),
|
||||
Item(name="Conjured Mana Cake", sell_in=3, quality=6), # <-- :O
|
||||
]
|
||||
|
||||
days = 2
|
||||
import sys
|
||||
if len(sys.argv) > 1:
|
||||
@ -28,3 +28,7 @@ if __name__ == "__main__":
|
||||
print(item)
|
||||
print("")
|
||||
GildedRose(items).update_quality()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user