Skip to content

Commit edff792

Browse files
author
Brandon Duffany
committed
Fix some broken tests
Fixed broken tests due to bug in `temp_copy`. The following tests are currently flaky: - TestLibraryExamples.test_compile_all_libraries (fails _sometimes_ with exception 'window.selectedBoard is undefined') - TestHome.test_login (passes _always_ when run on its own, fails _always_ when run with other tests)
1 parent 2a67857 commit edff792

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

codebender_testing/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import json
55
import os
66
import re
7+
import shutil
78
import tempfile
89

910
from selenium.common.exceptions import NoSuchElementException
@@ -77,9 +78,8 @@ def temp_copy(fname):
7778
"""
7879
extension = fname.split('.')[-1]
7980
with tempfile.NamedTemporaryFile(mode='w+b', suffix='.%s' % extension) as copy:
80-
with open(fname, 'r') as original:
81-
for line in original:
82-
copy.write(line)
81+
with open(fname, 'rb') as original:
82+
shutil.copyfileobj(original, copy)
8383
copy.flush()
8484
yield copy
8585

tests/compile_tester/test_compile_tester_projects.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ def test_compile_local_files(self, tester_login):
2828
"""Tests that we can upload all of cb_compile_tester's projects
2929
(stored locally in test_data/cb_compile_tester), compile them,
3030
and finally delete them."""
31+
upload_limit = None if self.run_full_compile_tests else 1
32+
3133
test_files = [os.path.join(COMPILE_TESTER_DIR, name)
32-
for name in next(os.walk(COMPILE_TESTER_DIR))[2]]
34+
for name in next(os.walk(COMPILE_TESTER_DIR))[2]][:upload_limit]
3335
projects = [self.upload_project(fname) for fname in test_files]
3436
project_names, project_urls = zip(*projects)
3537

0 commit comments

Comments
 (0)