How to tag and execute test cases with smoke or regression using PyTest?

 You can mark a test function using custom meta data:

@pytest.mark.smoke
def mytest1():
    pass  # perform some web test test for your app

@pytest.mark.regression
def mytest1():
    pass  # perform some web test test for your app

In above code smoke and regression are tag name.

You can then restrict a test run to only run tests marked with smoke or regression:

pytest -v -m smoke