JosephLai241 / URS

Universal Reddit Scraper - A comprehensive Reddit scraping/archival command-line tool.
https://josephlai241.github.io/URS/
MIT License
780 stars 105 forks source link

How can I ran the test case on my local? #46

Closed rex-wang122 closed 2 years ago

rex-wang122 commented 2 years ago

I want to run the unittest added in the tests folder, what command should I use?

JosephLai241 commented 2 years ago

Note: These steps assume you are cd'ed into the URS directory.

Setting up a Virtual Environment

First you should create a virtual environment. I use venv so the command to create a virtual environment named env would be:

$ python -m venv env

Then activate the virtual environment:

$ source env/bin/activate

Your terminal should now display some kind of indication that you are in the virtual environment. I believe the most common indication is an (env) next to the prompt, assuming you have not done any heavy customization for your terminal.

Your virtual environment should be activated for the following steps.

Installing Dependencies and pytest

You will have to install URS's dependencies and pytest in the virtual environment:

$ pip install -r requirements.txt
$ pip install pytest

Running pytest

Now you can run the test suite on your local machine:

$ python -m pytest

Once you are done with the virtual environment, you can deactivate it like so:

$ deactivate

The environment indication in your terminal's prompt should not be displayed anymore.

Potential Local Failures

Depending on how your machine's clock was configured, there may be 11 local failures when you run pytest. If you encounter these errors, keep in mind these are unique to your machine and not an issue with URS.

These are the tests that may trigger the local failures: