Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Jaime Collado
/
textflow
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
1
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
e146fd66
authored
Apr 22, 2022
by
Estrella Vallecillo
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Fixing some sequence tests
parent
77873cd9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
16 deletions
tests/test_sequence.py
textflow/Sequence.py
tests/test_sequence.py
View file @
e146fd66
...
...
@@ -18,6 +18,11 @@ def test_sequence_wrong_format():
Sequence
(
"text"
,
"tests/data/doc_1.txt"
),
"Lorem ipsum dolor sit amet
\n
Nam lectus turpis"
)
,
pytest
.
param
(
Sequence
(
"directory"
,
"tests/data"
),
" "
)
]
)
def
test_str
(
sequence
,
expected
):
...
...
@@ -57,10 +62,14 @@ def test_str(sequence, expected):
[
pytest
.
param
(
Sequence
(
"string"
,
"Lorem ipsum dolor sit amet"
),
5
1
),
pytest
.
param
(
Sequence
(
"text"
,
"tests/data/doc_1.txt"
),
1
),
pytest
.
param
(
Sequence
(
"directory"
,
"tests/data"
),
2
)
]
...
...
@@ -74,10 +83,7 @@ def test_len(sequence, expected):
[
pytest
.
param
(
Sequence
(
"string"
,
"Lorem ipsum"
),
{
"child"
:
(
"token"
,
"Lorem"
),
"sequence"
:
Sequence
()
}
[
Sequence
()
for
_
in
range
(
2
)]
),
pytest
.
param
(
Sequence
(
"text"
,
"tests/data/doc_1.txt"
),
...
...
@@ -85,6 +91,10 @@ def test_len(sequence, expected):
"child"
:
[(
"string"
,
"Lorem ipsum dolor sit amet"
),
(
"string"
,
"Nam lectus turpis"
)],
"sequence"
:
[
Sequence
()
for
_
in
range
(
2
)]
}
),
pytest
.
param
(
Sequence
(
"directory"
,
"tests/data"
),
2
)
]
)
...
...
@@ -96,17 +106,15 @@ def test_iter(sequence, expected):
[
pytest
.
param
(
Sequence
(
"string"
,
"Lorem ipsum dolor sit amet"
),
{
"child"
:
(
"token"
,
"Lorem"
),
"sequence"
:
Sequence
()
}
[
Sequence
()
for
_
in
range
(
5
)]
),
pytest
.
param
(
Sequence
(
"text"
,
"tests/data/doc_1.txt"
),
{
"chile"
:
(
"string"
,
"Lorem ipsum dolor sit amet"
),
"sequence"
:
Sequence
()
}
[
Sequence
()
for
_
in
range
(
8
)]
),
pytest
.
param
(
Sequence
(
"directory"
,
"tests/data"
),
2
)
]
)
...
...
@@ -114,8 +122,25 @@ def test_getitem(sequence, expected):
assert
sequence
[
0
]
==
expected
def
test_get_depth
():
pass
@pytest.mark.parametrize
(
"sequence, expected"
,
[
pytest
.
param
(
Sequence
(
"string"
,
"Lorem ipsum dolor sit amet"
),
(
1
,[
"tokens"
])
),
pytest
.
param
(
Sequence
(
"text"
,
"tests/data/doc_1.txt"
),
(
1
,
[
"tokens"
])
),
pytest
.
param
(
Sequence
(
"directory"
,
"tests/data"
),
(
2
,
[
"files"
,
"tokens"
])
)
]
)
def
test_get_depth
(
sequence
,
expected
):
assert
sequence
.
depth
()
==
expected
def
test_filter
():
...
...
textflow/Sequence.py
View file @
e146fd66
...
...
@@ -64,7 +64,7 @@ class Sequence:
self
.
format
=
format
self
.
children
=
{}
self
.
metadata
=
{}
self
.
metadata
=
{
"text"
:
" "
}
if
format
==
"token"
:
if
not
isinstance
(
src
,
str
):
raise
ValueError
(
f
"{src} is not an instance of token"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment