<commit_before># -*- coding: utf-8 -*-

from __future__ import (division, absolute_import, unicode_literals,
                        print_function)

import pytest

from file_metadata.image.image_file import ImageFile
from tests import fetch_file, unittest


class ImageFileTest(unittest.TestCase):

    def test_ndarray_read(self):
        _file = ImageFile(fetch_file('ball.png'))
        self.assertEqual(_file.fetch('ndarray').shape, (226, 226, 4))

    def test_huge_ndarray(self):
        _file = ImageFile(fetch_file('huge.png'))
        self.assertEqual(_file.fetch('ndarray').shape, (0,))


class ImageFileSoftwaresTest(unittest.TestCase):

    def test_created_with_unknown(self):
        _file = ImageFile(fetch_file('red.svg'))
        self.assertEqual(_file.analyze_softwares(), {})

    def test_created_with_inkscape(self):
        _file = ImageFile(fetch_file('created_with_inkscape.svg'))
        data = _file.analyze_softwares().get('Composite:Softwares', None)
        self.assertIn('Inkscape', data)

    def test_created_with_matlab(self):
        _file = ImageFile(fetch_file('created_with_matlab.png'))
        data = _file.analyze_softwares().get('Composite:Softwares', None)
        self.assertIn('MATLAB', data)

    def test_created_with_imagemagick(self):
        _file = ImageFile(fetch_file('created_with_imagemagick.png'))
        data = _file.analyze_softwares().get('Composite:Softwares', None)
        self.assertIn('ImageMagick', data)

    def test_created_with_adobe_imageready(self):
        _file = ImageFile(fetch_file('created_with_adobe_imageready.png'))
        data = _file.analyze_softwares().get('Composite:Softwares', None)
        self.assertIn('Adobe ImageReady', data)

    def test_created_with_adobe_photoshop(self):
        _file = ImageFile(fetch_file('created_with_adobe_photoshop.jpg'))
        data = _file.analyze_softwares().get('Composite:Softwares', None)
        self.assertIn('Adobe Photoshop', data)

    def test_created_with_adobe_photoshop_express(self):
        _file = ImageFile(fetch_file(
            'created_with_adobe_photoshop_express.jpg'))
        data = _file.analyze_softwares().get('Composite:Softwares', None)
        self.assertIn('Adobe Photoshop Express', data)

    def test_created_with_adobe_photoshop_elements(self):
        _file = ImageFile(fetch_file(
            'created_with_adobe_photoshop_elements.jpg'))
        data = _file.analyze_softwares().get('Composite:Softwares', None)
        self.assertIn('Adobe Photoshop Elements', data)

    def test_created_with_photoshop_photomerge(self):
        _file = ImageFile(fetch_file(
            'created_with_photoshop_photomerge.jpg'))
        data = _file.analyze_softwares().get('Composite:Softwares', None)
        self.assertIn('Photoshop Photomerge', data)

    def test_created_with_picasa(self):
        _file = ImageFile(fetch_file('created_with_picasa.jpg'))
        data = _file.analyze_softwares().get('Composite:Softwares', None)<commit_msg>Fix travis issues with tests<commit_after># -*- coding: utf-8 -*-

from __future__ import (division, absolute_import, unicode_literals,
                        print_function)

import pytest

from file_metadata.image.image_file import ImageFile
from tests import fetch_file, unittest


class ImageFileTest(unittest.TestCase):

    def test_ndarray_read(self):
        _file = ImageFile(fetch_file('ball.png'))
        self.assertEqual(_file.fetch('ndarray').shape, (226, 226, 4))

    def test_huge_ndarray(self):
        _file = ImageFile(fetch_file('huge.png'))
        self.assertEqual(_file.fetch('ndarray').shape, (0,))


class ImageFileSoftwaresTest(unittest.TestCase):

    def test_created_with_unknown(self):
        _file = ImageFile(fetch_file('red.svg'))
        self.assertEqual(_file.analyze_softwares(), {})

    def test_created_with_inkscape(self):
        _file = ImageFile(fetch_file('created_with_inkscape.svg'))
        data = _file.analyze_softwares().get('Composite:Softwares', None)
        self.assertIn('Inkscape', data)

    def test_created_with_matlab(self):
        _file = ImageFile(fetch_file('created_with_matlab.png'))
        data = _file.analyze_softwares().get('Composite:Softwares', None)
        self.assertIn('MATLAB', data)

    def test_created_with_imagemagick(self):
        _file = ImageFile(fetch_file('created_with_imagemagick.png'))
        data = _file.analyze_softwares().get('Composite:Softwares', None)
        self.assertIn('ImageMagick', data)

    def test_created_with_adobe_imageready(self):
        _file = ImageFile(fetch_file('created_with_adobe_imageready.png'))
        data = _file.analyze_softwares().get('Composite:Softwares', None)
        self.assertIn('Adobe ImageReady', data)

    def test_created_with_adobe_photoshop(self):
        _file = ImageFile(fetch_file('created_with_adobe_photoshop.jpg'))
        data = _file.analyze_softwares().get('Composite:Softwares', None)
        self.assertIn('Adobe Photoshop', data)

    def test_created_with_adobe_photoshop_express(self):
        _file = ImageFile(fetch_file(
            'created_with_adobe_photoshop_express.jpg'))
        data = _file.analyze_softwares().get('Composite:Softwares', None)
        self.assertIn('Adobe Photoshop Express', data)

    def test_created_with_adobe_photoshop_elements(self):
        _file = ImageFile(fetch_file(
            'created_with_adobe_photoshop_elements.jpg'))
        data = _file.analyze_softwares().get('Composite:Softwares', None)
        self.assertIn('Adobe Photoshop Elements', data)

    def test_created_with_photoshop_photomerge(self):
        _file = ImageFile(fetch_file(
            'created_with_photoshop_photomerge.jpg'))
        data = _file.analyze_softwares().get('Composite:Softwares', None)
        if float(_file.exiftool()['ExifTool:ExifToolVersion']) >= 10:
            # Older versions of exiftool do not detect this correctly. Hence
            # we only do the test in newer versions.
            self.assertIn('Photoshop Photomerge', data)

    def test_created_with_picasa(self):
        _file = ImageFile(fetch_file('created_with_picasa.jpg'))
        data = _file.analyze_softwares().get('Composite:Softwares', None)
{'fraction_non_alphanumeric': 0.11322274118215493, 'fraction_numerical': 0.003221130616846513, 'mean_word_length': 3.944267515923567, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6177189', 'n_tokens_mistral': 2051, 'n_tokens_neox': 1953, 'n_words': 290}