Created
December 16, 2013 16:33
-
-
Save hltbra/7989959 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # WRONG | |
| def test_open_and_delete_file(): | |
| f = open(FILEPATH) | |
| content = f.read() | |
| assert content == "hello world" | |
| content.close() | |
| # RIGHT | |
| def test_open_and_delete_file(): | |
| f = open(FILEPATH) | |
| try: | |
| content = f.read() | |
| assert content == "hello world" | |
| finally: | |
| content.close() | |
| # WRONG | |
| def test_create_user(): | |
| u = create_user(username="test") | |
| assert count_users() == 1 | |
| flush_db() | |
| # RIGHT | |
| def test_create_user(): | |
| try: | |
| u = create_user(username="test") | |
| assert count_users() == 1 | |
| finally: | |
| flush_db() | |
| # WRONG | |
| def test_create_multiple_users(): | |
| u = create_users(usernames=["test", "test2"]) | |
| assert count_users() == 2 | |
| flush_db() | |
| # RIGHT | |
| def test_create_multiple_users(): | |
| try: | |
| u = create_users(usernames=["test", "test2"]) | |
| assert count_users() == 2 | |
| finally: | |
| flush_db() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment