Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Language Detection
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
1MAE002 - ALGORITHM AND COMPUTING
Language Detection
Commits
9dc59e23
Verified
Commit
9dc59e23
authored
Sep 17, 2024
by
STEVAN Antoine
Browse files
Options
Downloads
Patches
Plain Diff
test: give better error messages for `read_text`
parent
63871057
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_read_text.py
+22
-4
22 additions, 4 deletions
tests/test_read_text.py
with
22 additions
and
4 deletions
tests/test_read_text.py
+
22
−
4
View file @
9dc59e23
def
test_read_text
():
from
src.enhanced_occurrence_frequencies
import
read_text
assert
read_text
(
"
tests/sample.txt
"
)
==
"
this is a sample text file
\n
"
assert
read_text
(
"
tests/empty.txt
"
)
==
""
assert
read_text
(
"
tests/multiline.txt
"
)
==
"
i
\n
am
\n
a
\n
multiline
\n
text
\n
"
assert
read_text
(
"
tests/symbols.txt
"
)
==
"
this is a (sample) text, containing (a lot of) punctuation!!
\n
"
for
(
file
,
expected
,
msg
)
in
[
(
"
tests/sample.txt
"
,
"
this is a sample text file
\n
"
,
None
),
(
"
tests/empty.txt
"
,
""
,
"
`read_text` should give an empty string for an empty file
"
,
),
(
"
tests/multiline.txt
"
,
"
i
\n
am
\n
a
\n
multiline
\n
text
\n
"
,
"
`read_text` should handle newlines
"
,
),
(
"
tests/symbols.txt
"
,
"
this is a (sample) text, containing (a lot of) punctuation!!
\n
"
,
"
`read_text` should only make the text lower case, not remove symbols
"
,
),
]:
if
msg
is
not
None
:
assert
read_text
(
file
)
==
expected
,
msg
else
:
assert
read_text
(
file
)
==
expected
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment