Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
openpyxl
openpyxl
Commits
895bee9f6e4d
Commit
d33f6830
authored
May 22, 2022
by
Jahrules
Browse files
updated testcases for recent changes that were missing coverage as per the hepta pipeline
--HG-- branch : 3.1
parent
72955bc846d8
Pipeline
#54155
failed with stage
in 21 minutes and 40 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
openpyxl/utils/search.py
View file @
895bee9f
...
...
@@ -44,7 +44,7 @@ class Search:
def
__getitem__
(
self
,
index
):
if
not
self
.
_searched
:
return
None
self
.
find
()
# additional validation - the index ==0 or 1 check
# is there in case a user is using __getitem__ directly
...
...
openpyxl/utils/tests/test_search.py
View file @
895bee9f
...
...
@@ -47,6 +47,14 @@ def test_limit_err():
with
pytest
.
raises
(
ValueError
):
Search
(
ws
,
"str"
,
True
,[
'badarr'
])
def
test_getitem
():
wb
=
Workbook
()
ws
=
wb
.
active
search
=
Search
(
ws
,
"str"
)
res
=
search
[
0
]
assert
res
==
None
@
pytest
.
fixture
def
datadir
():
"""DATADIR as a LocalPath"""
...
...
@@ -172,6 +180,43 @@ def test_case_search(datadir, searchstring, results):
all_coords
.
append
(
cell
.
coordinate
)
assert
results
==
all_coords
@
pytest
.
mark
.
parametrize
(
"searchstring, results"
,
[
(
"Test Data 103"
,
[
"J94"
,
"I95"
,
"H96"
,
"G97"
,
"F98"
,
"E99"
,
"D100"
,
"C101"
,
"B102"
,
"A103"
]
),
(
"test Data 103"
,
[
"J94"
,
"I95"
,
"H96"
,
"G97"
,
"F98"
,
"E99"
,
"D100"
,
"C101"
,
"B102"
,
"A103"
]
),
(
"unique"
,
[
"K173"
]),
(
"NotExist"
,
None
)
]
)
def
test_case_rescan
(
datadir
,
searchstring
,
results
):
datadir
.
chdir
()
wb
=
load_workbook
(
filename
=
"Sample_Large.xlsx"
)
ws
=
wb
.
active
search
=
Search
(
ws
,
"test"
,
True
)
assert
search
.
search_term
==
"test"
assert
search
.
ignore_case
==
True
assert
search
.
limit
==
0
search
.
rescan
(
searchstring
)
assert
search
.
search_term
==
searchstring
res
=
search
.
find_all
()
if
results
==
None
:
assert
res
==
None
else
:
all_coords
=
[]
for
cell
in
res
:
all_coords
.
append
(
cell
.
coordinate
)
assert
results
==
all_coords
@
pytest
.
mark
.
parametrize
(
"searchstring, results"
,
[
(
"Test Data 10"
,
...
...
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