Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 76afe8d

Browse filesBrowse files
crwilcoxleahecolegcf-merge-on-green[bot]
authored
fix: create fixture with random file name for test (GoogleCloudPlatform#3067)
* fix: create fixture with random file name for test * fix: whitespace Co-authored-by: Leah E. Cole <6719667+leahecole@users.noreply.github.com> Co-authored-by: gcf-merge-on-green[bot] <60162190+gcf-merge-on-green[bot]@users.noreply.github.com>
1 parent e92dc6a commit 76afe8d
Copy full SHA for 76afe8d

File tree

Expand file treeCollapse file tree

1 file changed

+16
-2
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+16
-2
lines changed

‎storage/api/crud_object_test.py

Copy file name to clipboardExpand all lines: storage/api/crud_object_test.py
+16-2Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,28 @@
1313

1414
import os
1515
import re
16+
import tempfile
1617

1718
from crud_object import main
19+
import pytest
1820

1921
BUCKET = os.environ['CLOUD_STORAGE_BUCKET']
2022

2123

22-
def test_main(capsys):
23-
main(BUCKET, __file__)
24+
@pytest.fixture()
25+
def test_file():
26+
_, file_path = tempfile.mkstemp()
27+
28+
with open(file_path, "w+b") as f:
29+
f.write(b"hello world")
30+
31+
yield file_path
32+
33+
os.remove(file_path)
34+
35+
36+
def test_main(capsys, test_file):
37+
main(BUCKET, test_file)
2438
out, err = capsys.readouterr()
2539

2640
assert not re.search(r'Downloaded file [!]=', out)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.