I've run your code and it is working fine and giving Assertion error as well.
Here, it seems that you are running the test as normal python file.
You need to run your file as pytest test. For that you need to setup pytest configuration.
In pycharm, Go to Run -> Edit Configurations... Then click the + in the upper left of the modal dialog. Select "python tests" -> py.test Then I give it a name like "All test with py.test"
select Target: module name or path to your test file > click on OK
Now from Run menu select run "All test with py.test" or press shift+ f10
Help link : How do I configure PyCharm to run py.test tests?