diff options
| author | Cody Logan <cody@lokken.dev> | 2023-10-23 12:08:08 -0700 |
|---|---|---|
| committer | Cody Logan <cody@lokken.dev> | 2023-10-23 12:32:05 -0700 |
| commit | daf4a17b53ed59ffa4b130ce9bedd4f42ef1bfdb (patch) | |
| tree | 7163641d5f71ba9e7a5d8d905cfc742c0f804fe1 /tests/test_file_class.py | |
| parent | 775fb9e663d1704302cbc2329e9538c0c4353bf5 (diff) | |
| download | wikiget-daf4a17b53ed59ffa4b130ce9bedd4f42ef1bfdb.tar.gz wikiget-daf4a17b53ed59ffa4b130ce9bedd4f42ef1bfdb.zip | |
Reorganize tests using fixtures
Diffstat (limited to 'tests/test_file_class.py')
| -rw-r--r-- | tests/test_file_class.py | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/tests/test_file_class.py b/tests/test_file_class.py index dd30207..1b76566 100644 --- a/tests/test_file_class.py +++ b/tests/test_file_class.py @@ -15,23 +15,36 @@ # You should have received a copy of the GNU General Public License # along with Wikiget. If not, see <https://www.gnu.org/licenses/>. +import pytest + from wikiget import DEFAULT_SITE from wikiget.file import File -def test_file_with_name_only(): - file = File("foobar.jpg") - assert file.name == "foobar.jpg" - assert file.dest == file.name - assert file.site == DEFAULT_SITE +class TestFileClass: + @pytest.fixture(scope="class") + def file_with_name(self) -> File: + return File("foobar.jpg") + + def test_file_with_name(self, file_with_name: File) -> None: + assert file_with_name.name == "foobar.jpg" + + def test_file_with_name_dest(self, file_with_name: File) -> None: + assert file_with_name.dest == file_with_name.name + + def test_file_with_name_site(self, file_with_name: File) -> None: + assert file_with_name.site == DEFAULT_SITE + @pytest.fixture(scope="class") + def file_with_name_and_dest(self) -> File: + return File("foobar.jpg", dest="bazqux.jpg") -def test_file_with_name_and_dest(): - file = File("foobar.jpg", dest="bazqux.jpg") - assert file.dest == "bazqux.jpg" - assert file.dest != file.name + def test_file_with_name_and_dest(self, file_with_name_and_dest: File) -> None: + assert file_with_name_and_dest.dest == "bazqux.jpg" + def test_name_and_dest_are_different(self, file_with_name_and_dest: File) -> None: + assert file_with_name_and_dest.dest != file_with_name_and_dest.name -def test_file_with_name_and_site(): - file = File("foobar.jpg", site="en.wikipedia.org") - assert file.site == "en.wikipedia.org" + def test_file_with_name_and_site(self) -> None: + file = File("foobar.jpg", site="en.wikipedia.org") + assert file.site == "en.wikipedia.org" |
