Skip to content

Commit

Permalink
add bs4 to attempt windows utf-8 reading
Browse files Browse the repository at this point in the history
  • Loading branch information
bollwyvl committed Sep 5, 2020
1 parent 4953232 commit 12fe40d
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 8 deletions.
11 changes: 5 additions & 6 deletions atest/Keywords.robot
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Library SeleniumLibrary
Library OperatingSystem
Library Process
Library String
Library ./logcheck.py
Library ./ports.py

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

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

Wait For Splash
Go To ${URL}lab?reset&token=${TOKEN}
Expand Down
24 changes: 24 additions & 0 deletions atest/logcheck.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import os

from bs4 import UnicodeDammit


def file_should_not_contain_phrases(filename, offset=0, *phrases):
"""don't fail _too_ hard if the file can't be read for soem reason"""
with open(filename, "rb") as fp:
raw = fp.read()[offset:]

text = None

try:
text = raw.decode("utf-8")
except Exception as err:
text = UnicodeDammit.detwingle(raw).decode("utf-8")

matches = {}

for phrase in phrases:
if phrase in text:
matches[phrase] = True

assert not matches, "Phrases found in {}: {}".format(filename, matches)
3 changes: 2 additions & 1 deletion ci/env-test.yml.in
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ dependencies:
- pytest-runner
- ruamel_yaml
# browser testing
- bs4
- firefox
- geckodriver
- robotframework-seleniumlibrary
- robotframework >=3.2
- robotframework-seleniumlibrary
3 changes: 2 additions & 1 deletion requirements/atest.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# acceptance test dependencies for jupyter_lsp
-r ./lab.txt
robotframework-seleniumlibrary
bs4
robotframework >=3.2
robotframework-seleniumlibrary

0 comments on commit 12fe40d

Please sign in to comment.