I actually got nosetests working before I reset my laptop. However, after resetting my laptop this afternoon, and after I reinstalled everything, I suddenly got ran 0 tests problem. So I decided to switch to pytest because I saw a lot of people recommended pytest in this forum. After installing pytest, I still got collected 0 items problem.
(I’m 100% sure syntax and folders are correct, they worked for nosetests before but not now.)
Below are my pytest code:
import pytest
from ex47.game import Room
def test_room():
gold = Room("GoldRoom",
"""This room has gold in it you can grab. There's a
door to the north.""")
assert gold.name == "GoldRoom"
assert gold.paths == {}
def test_room_paths():
center = Room("Center", "Test room in the center.")
north = Room("North", "Test room in the north.")
south = Room("South", "Test room in the south.")
center.add_paths({'north': north, 'south': south})
assert center.go('north') == north
assert center.go('south') == south
def test_map():
start = Room("Start", "You can go west and down a hole.")
west = Room("Trees", "There are trees here, you can go esat.")
down = Room("Dungeon", "It's dark down here, you can go up.")
start.add_paths({'west': west, 'down': down})
west.add_paths({'east': start})
down.add_paths({'up': start})
assert start.go('west') == west
assert start.go('west').go('east') == start
assert start.go('down').go('up') == start
Below is the terminal output:
(lpthw) PS C:\Users\shane\lpthw\ex47\skeleton> pytest
================================= test session starts ============================
platform win32 -- Python 3.8.3, pytest-5.4.3, py-1.8.1, pluggy-0.13.1
rootdir: C:\Users\shane\lpthw\ex47\skeleton
collected 0 items
================================= no tests ran in 0.03s ==========================
PS: I’m working on Visual Studio Code and the interpreter path is set to the virtual environment (.venvs/lpthw/Scripts/python). I installed both nose and pytest in virtual environment so I have to start from here otherwise vscode throws “pylint unable to import blahblah” problem.
Not sure which part went wrong, need some help!
Thanks in advance!