Skip to content

Commit 12fe40d

Browse files
committed
add bs4 to attempt windows utf-8 reading
1 parent 4953232 commit 12fe40d

File tree

4 files changed

+33
-8
lines changed

4 files changed

+33
-8
lines changed

atest/Keywords.robot

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Library SeleniumLibrary
44
Library OperatingSystem
55
Library Process
66
Library String
7+
Library ./logcheck.py
78
Library ./ports.py
89

910
*** Keywords ***
@@ -70,12 +71,10 @@ Tear Down Everything
7071
Terminate All Processes kill=${True}
7172

7273
Lab Log Should Not Contain Known Error Messages
73-
${log} = Get File ${LAB LOG}
74-
${test log} = Set Variable ${log[${PREVIOUS LAB LOG LENGTH}:]}
75-
${length} = Get Length ${log}
76-
Set Global Variable ${PREVIOUS LAB LOG LENGTH} ${length}
77-
Run Keyword If ("${OS}", "${PY}") !\= ("Windows", "36")
78-
... Should Not Contain Any ${test log} @{KNOWN BAD ERRORS}
74+
Touch ${LAB LOG}
75+
${length} = Get File Size ${LAB LOG}
76+
File Should Not Contain Phrases ${LAB LOG} ${PREVIOUS LAB LOG LENGTH} @{KNOWN BAD ERRORS}
77+
[Teardown] Set Global Variable ${PREVIOUS LAB LOG LENGTH} ${length}
7978

8079
Wait For Splash
8180
Go To ${URL}lab?reset&token=${TOKEN}

atest/logcheck.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import os
2+
3+
from bs4 import UnicodeDammit
4+
5+
6+
def file_should_not_contain_phrases(filename, offset=0, *phrases):
7+
"""don't fail _too_ hard if the file can't be read for soem reason"""
8+
with open(filename, "rb") as fp:
9+
raw = fp.read()[offset:]
10+
11+
text = None
12+
13+
try:
14+
text = raw.decode("utf-8")
15+
except Exception as err:
16+
text = UnicodeDammit.detwingle(raw).decode("utf-8")
17+
18+
matches = {}
19+
20+
for phrase in phrases:
21+
if phrase in text:
22+
matches[phrase] = True
23+
24+
assert not matches, "Phrases found in {}: {}".format(filename, matches)

ci/env-test.yml.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ dependencies:
3333
- pytest-runner
3434
- ruamel_yaml
3535
# browser testing
36+
- bs4
3637
- firefox
3738
- geckodriver
38-
- robotframework-seleniumlibrary
3939
- robotframework >=3.2
40+
- robotframework-seleniumlibrary

requirements/atest.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# acceptance test dependencies for jupyter_lsp
22
-r ./lab.txt
3-
robotframework-seleniumlibrary
3+
bs4
44
robotframework >=3.2
5+
robotframework-seleniumlibrary

0 commit comments

Comments
 (0)