Commit c35c56b6 authored by Gabriel Monnerat's avatar Gabriel Monnerat

Fix test and use python-magic

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@42111 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 236565c4
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
import unittest import unittest
import json import json
import magic
import pkg_resources import pkg_resources
from subprocess import Popen, PIPE from subprocess import Popen, PIPE
from os.path import exists, join from os.path import exists, join
...@@ -80,15 +81,9 @@ class TestUnoConverter(CloudoooTestCase): ...@@ -80,15 +81,9 @@ class TestUnoConverter(CloudoooTestCase):
self.assertEquals(stderr, '') self.assertEquals(stderr, '')
output_url = stdout.replace('\n', '') output_url = stdout.replace('\n', '')
self.assertTrue(exists(output_url), stdout) self.assertTrue(exists(output_url), stdout)
command = [file, output_url] file_detector = magic.Magic()
stdout, stderr = Popen(command, magic_result = file_detector.from_buffer(output_url)
stdout=PIPE, self.assertTrue(magic_result.startswith("ASCII text"))
stderr=PIPE).communicate()
self.assertEquals(self.file_msg_list[1] in stdout \
or \
self.file_msg_list[0] in stdout,
True,
"%s don't have %s" % (self.file_msg_list, stdout))
self.document.trash() self.document.trash()
self.assertEquals(exists(output_url), False) self.assertEquals(exists(output_url), False)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment