Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
mat2
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
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
tails
mat2
Commits
a1257c53
Commit
a1257c53
authored
6 years ago
by
Julien (jvoisin) Voisin
Browse files
Options
Downloads
Patches
Plain Diff
Add some tests about pathological files
parent
6d8e999f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_corrupted_files.py
+35
-0
35 additions, 0 deletions
tests/test_corrupted_files.py
with
35 additions
and
0 deletions
tests/test_corrupted_files.py
+
35
−
0
View file @
a1257c53
...
...
@@ -7,6 +7,41 @@ import os
from
libmat2
import
pdf
,
images
,
audio
,
office
,
parser_factory
,
torrent
,
harmless
class
TestInexistentFiles
(
unittest
.
TestCase
):
def
test_ro
(
self
):
parser
,
mimetype
=
parser_factory
.
get_parser
(
'
/etc/passwd
'
)
self
.
assertEqual
(
mimetype
,
None
)
self
.
assertEqual
(
parser
,
None
)
def
test_notaccessible
(
self
):
parser
,
mimetype
=
parser_factory
.
get_parser
(
'
/etc/shadow
'
)
self
.
assertEqual
(
mimetype
,
None
)
self
.
assertEqual
(
parser
,
None
)
def
test_folder
(
self
):
parser
,
mimetype
=
parser_factory
.
get_parser
(
'
./tests/
'
)
self
.
assertEqual
(
mimetype
,
None
)
self
.
assertEqual
(
parser
,
None
)
def
test_inexistingfile
(
self
):
parser
,
mimetype
=
parser_factory
.
get_parser
(
'
./tests/NONEXISTING_FILE
'
)
self
.
assertEqual
(
mimetype
,
None
)
self
.
assertEqual
(
parser
,
None
)
def
test_chardevice
(
self
):
parser
,
mimetype
=
parser_factory
.
get_parser
(
'
/dev/zero
'
)
self
.
assertEqual
(
mimetype
,
None
)
self
.
assertEqual
(
parser
,
None
)
def
test_brokensymlink
(
self
):
shutil
.
copy
(
'
./tests/test_libmat2.py
'
,
'
./tests/clean.py
'
)
os
.
symlink
(
'
./tests/clean.py
'
,
'
./tests/SYMLINK
'
)
os
.
remove
(
'
./tests/clean.py
'
)
parser
,
mimetype
=
parser_factory
.
get_parser
(
'
./tests/SYMLINK
'
)
self
.
assertEqual
(
mimetype
,
None
)
self
.
assertEqual
(
parser
,
None
)
os
.
unlink
(
'
./tests/SYMLINK
'
)
class
TestUnsupportedFiles
(
unittest
.
TestCase
):
def
test_pdf
(
self
):
shutil
.
copy
(
'
./tests/test_libmat2.py
'
,
'
./tests/clean.py
'
)
...
...
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