Skip to content
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
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ jobs:
contents: read
strategy:
fail-fast: false
max-parallel: 1
matrix:
os: [macos-15-intel, macos-latest, windows-latest, ubuntu-latest]
python-version: ["3.11", "3.12", "3.13"]
Expand Down
39 changes: 28 additions & 11 deletions test/integration/test_dropbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import re
import string
import sys
import uuid
import pytest

import dropbox.dropbox_client as dropbox_client
Expand Down Expand Up @@ -37,6 +38,7 @@
ListFolderError,
PathOrLink,
SharedLinkFileInfo,
WriteMode,
)
from dropbox.common import (
PathRoot,
Expand Down Expand Up @@ -157,23 +159,37 @@ def dbx_share_url_from_env():

RANDOM_FOLDER = random.sample(string.ascii_letters, 15)
TIMESTAMP = str(datetime.datetime.now(datetime.timezone.utc))
STATIC_FILE = "/test.txt"
# Unique per test process (once per pytest run = once per CI workflow run) so
# concurrent runs against the shared test account never collide on the same
# paths. See test/integration/README or CI notes for why this matters.
RUN_ID = "%s-%s" % (TIMESTAMP, uuid.uuid4().hex)
TEST_FOLDER = "/Test/%s" % RUN_ID
STATIC_FILE = "%s/test.txt" % TEST_FOLDER


@pytest.fixture(scope="module")
def pytest_setup():
print("Setup")
dbx = _refresh_dbx()

try:
dbx.files_delete(STATIC_FILE)
except Exception:
print("File not found")
# Paths are unique per run, but clean up defensively in case a prior aborted
# run left this run's namespace behind (extremely unlikely with the UUID).
for path in (TEST_FOLDER, "/Test/%s" % TIMESTAMP):
try:
dbx.files_delete_v2(path)
except Exception:
print("File not found: %s" % path)

try:
dbx.files_delete("/Test/%s" % TIMESTAMP)
except Exception:
print("File not found")
yield

# Teardown: always remove this run's namespace so the shared test account
# does not accumulate cruft and stale files cannot poison later runs.
print("Teardown")
for path in (TEST_FOLDER, "/Test/%s" % TIMESTAMP):
try:
dbx.files_delete_v2(path)
except Exception:
print("Nothing to clean up: %s" % path)


@pytest.mark.usefixtures(
Expand Down Expand Up @@ -304,8 +320,9 @@ def test_path_root_err(self, dbx_from_env):
assert cm.value.error.is_invalid_root()

def test_versioned_route(self, dbx_from_env):
# Upload a test file
dbx_from_env.files_upload(DUMMY_PAYLOAD, STATIC_FILE)
# Upload a test file. Use overwrite so a leftover file from an aborted
# run cannot cause a spurious write conflict.
dbx_from_env.files_upload(DUMMY_PAYLOAD, STATIC_FILE, mode=WriteMode.overwrite)

# Delete the file with v2 route
resp = dbx_from_env.files_delete_v2(STATIC_FILE)
Expand Down
Loading