Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pytest for win #7518

Merged
merged 1 commit into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/vars/pytest.env
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
PYTEST_ARGUMENTS='--randomly-seed=1 --disable-warnings --reruns 1 --reruns-delay 1 --verbose --durations=3'

PYTEST_CORE_ARGUMENTS='./src/tribler/core ${PYTEST_ARGUMENTS}'
PYTEST_CORE_ARGUMENTS_WIN='${PYTEST_CORE_ARGUMENTS}'
PYTEST_CORE_ARGUMENTS_WIN='${PYTEST_CORE_ARGUMENTS} --no-looptime'
PYTEST_CORE_ARGUMENTS_LINUX='${PYTEST_CORE_ARGUMENTS} --looptime'
PYTEST_CORE_ARGUMENTS_MAC='${PYTEST_CORE_ARGUMENTS} --looptime'

PYTEST_TUNNELS_ARGUMENTS='./src/tribler/core/components/tunnel/tests/test_full_session --tunneltests ${PYTEST_ARGUMENTS}'
PYTEST_TUNNELS_ARGUMENTS_WIN='${PYTEST_TUNNELS_ARGUMENTS}'
PYTEST_TUNNELS_ARGUMENTS_WIN='${PYTEST_TUNNELS_ARGUMENTS} --no-looptime'
PYTEST_TUNNELS_ARGUMENTS_LINUX='${PYTEST_TUNNELS_ARGUMENTS} --looptime'
PYTEST_TUNNELS_ARGUMENTS_MAC='${PYTEST_TUNNELS_ARGUMENTS} --looptime'

PYTEST_GUI_ARGUMENTS='./src/tribler/gui --guitests ${PYTEST_ARGUMENTS}'
PYTEST_GUI_ARGUMENTS_WIN='${PYTEST_GUI_ARGUMENTS}'
PYTEST_GUI_ARGUMENTS_WIN='${PYTEST_GUI_ARGUMENTS} --no-looptime'
PYTEST_GUI_ARGUMENTS_LINUX='${PYTEST_GUI_ARGUMENTS} --looptime'
PYTEST_GUI_ARGUMENTS_MAC='${PYTEST_GUI_ARGUMENTS} --looptime'
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ async def transfer():
await protocol_task_group.wait()


@pytest.mark.looptime(start=42)
def test_update(transfer: Transfer):
# In this test we ensure that `transfer.update` method sets `time.time` value
# to `transfer.updated` property.
transfer.loop.time = Mock(return_value=42)

transfer.update()

assert transfer.updated == 42
Expand Down Expand Up @@ -252,9 +253,9 @@ async def test_format_attempt(transfer: Transfer):
assert transfer._format_attempt(remains=0, maximum=3) == '3/3'


@pytest.mark.looptime(start=10)
async def test_remaining(transfer: Transfer):
# Imagine that now time is `10` and transfer has been updated in `0`
transfer.loop.time = Mock(return_value=10)
transfer.updated = 0

assert transfer._remaining(5) == -5
Expand Down