Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
ICARTT Python Package
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MBEES
ICARTT Python Package
Commits
5c8799d9
Commit
5c8799d9
authored
3 years ago
by
Florian Obersteiner
Browse files
Options
Downloads
Patches
Plain Diff
prepared fail test
parent
304a3017
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!6
code refactor
This commit is part of merge request
!6
. Comments created here will be created in the context of that merge request.
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_dataset.py
+17
-12
17 additions, 12 deletions
tests/test_dataset.py
with
17 additions
and
12 deletions
tests/test_dataset.py
+
17
−
12
View file @
5c8799d9
...
...
@@ -7,7 +7,8 @@ import icartt
# working directory, example files
wd
=
pathlib
.
Path
(
__file__
).
parent
fns
=
(
wd
/
"
example_data
"
).
glob
(
"
*.ict
"
)
fns_pass
=
(
wd
/
"
example_data
"
).
glob
(
"
*.ict
"
)
fns_fail
=
(
wd
/
"
example_data
"
/
"
will_fail
"
).
glob
(
"
*.ict
"
)
def
compareFiles
(
fn
,
strIn
,
strOut
,
skiplines
=
0
,
nlines
=-
1
):
# pragma: no cover
...
...
@@ -310,42 +311,46 @@ class Create1001TestCase(unittest.TestCase):
class
BulkIOTestCase
(
unittest
.
TestCase
):
# def testInvalid(self):
# for fn in fns_fail:
# with self.subTest(msg=f"Opening invalid file {str(fn)}"):
# try:
# _ = icartt.Dataset(fn, loadData=True)
# except: # TODO: failure tests could be more specific
# pass
# else:
# self.fail('expected to fail')
def
testOpen
(
self
):
for
fn
in
fns
:
for
fn
in
fns
_pass
:
with
self
.
subTest
(
msg
=
f
"
Opening test file
{
str
(
fn
)
}
"
):
ict
=
icartt
.
Dataset
(
fn
,
loadData
=
False
)
self
.
assertEqual
(
type
(
ict
),
icartt
.
Dataset
)
def
testReadData
(
self
):
for
fn
in
fns
:
for
fn
in
fns
_pass
:
with
self
.
subTest
(
msg
=
f
"
Reading data from test file
{
str
(
fn
)
}
"
):
ict
=
icartt
.
Dataset
(
fn
,
loadData
=
True
)
self
.
assertEqual
(
type
(
ict
),
icartt
.
Dataset
)
def
testWriteHeader
(
self
):
for
fn
in
fns
:
for
fn
in
fns
_pass
:
with
self
.
subTest
(
msg
=
f
"
Writing header for test file
{
str
(
fn
)
}
"
):
ict
=
icartt
.
Dataset
(
fn
,
loadData
=
False
)
strIn
=
open
(
fn
)
strOut
=
io
.
StringIO
()
ict
.
writeHeader
(
f
=
strOut
)
self
.
assertTrue
(
compareFiles
(
fn
,
strIn
,
strOut
,
nlines
=
ict
.
nHeader
))
def
testWrite
(
self
):
for
fn
in
fns
:
for
fn
in
fns
_pass
:
with
self
.
subTest
(
msg
=
f
"
Writing data for test file
{
str
(
fn
)
}
"
):
ict
=
icartt
.
Dataset
(
fn
,
loadData
=
True
)
strIn
=
open
(
fn
)
strOut
=
io
.
StringIO
()
ict
.
write
(
f
=
strOut
)
self
.
assertTrue
(
compareFiles
(
fn
,
strIn
,
strOut
))
if
__name__
==
"
__main__
"
:
# pragma: no cover
unittest
.
main
()
\ No newline at end of file
unittest
.
main
()
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