File: test_fixtures_live.py

package info (click to toggle)
python-pytest-djangoapp 1.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 396 kB
  • sloc: python: 1,116; makefile: 114; sh: 6
file content (25 lines) | stat: -rw-r--r-- 770 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from unittest.mock import MagicMock

import pytest
from django import VERSION


@pytest.mark.skipif(VERSION < (4, 0), reason='For Django 4.0+')
def test_liveserver(liveserver, liveclient):

    with liveserver(host='localhost', port=33445) as server:
        assert server.url == 'http://localhost:33445'


@pytest.mark.skipif(VERSION < (4, 0), reason='For Django 4.0+')
def test_selenium(liveserver, liveclient, monkeypatch):

    monkeypatch.setattr('django.test.selenium.SeleniumTestCaseBase', MagicMock())

    with liveserver() as server:

        with liveclient('selenium', browser='firefox') as client:
            selenium = client.handle

            selenium.get(server.url)
            assert 'MagicMock' in f"{selenium.find_element('tag name', 'h1').text}"