/usr/lib/python3/dist-packages/guessit/test/test_quality.py is in python3-guessit 0.11.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# GuessIt - A library for guessing information from filenames
# Copyright (c) 2013 Nicolas Wack <wackou@gmail.com>
#
# GuessIt is free software; you can redistribute it and/or modify it under
# the terms of the Lesser GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# GuessIt is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# Lesser GNU General Public License for more details.
#
# You should have received a copy of the Lesser GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from __future__ import absolute_import, division, print_function, unicode_literals
from guessit.quality import best_quality, best_quality_properties
from guessit.containers import QualitiesContainer
from guessit.test.guessittest import *
class TestQuality(TestGuessit):
def test_container(self):
container = QualitiesContainer()
container.register_quality('color', 'red', 10)
container.register_quality('color', 'orange', 20)
container.register_quality('color', 'green', 30)
container.register_quality('context', 'sun', 100)
container.register_quality('context', 'sea', 200)
container.register_quality('context', 'sex', 300)
g1 = Guess()
g1['color'] = 'red'
g2 = Guess()
g2['color'] = 'green'
g3 = Guess()
g3['color'] = 'orange'
q3 = container.rate_quality(g3)
assert q3 == 20, "ORANGE should be rated 20. Don't ask why!"
q1 = container.rate_quality(g1)
q2 = container.rate_quality(g2)
assert q2 > q1, "GREEN should be greater than RED. Don't ask why!"
g1['context'] = 'sex'
g2['context'] = 'sun'
q1 = container.rate_quality(g1)
q2 = container.rate_quality(g2)
assert q1 > q2, "SEX should be greater than SUN. Don't ask why!"
assert container.best_quality(g1, g2) == g1, "RED&SEX should be better than GREEN&SUN. Don't ask why!"
assert container.best_quality_properties(['color'], g1, g2) == g2, \
"GREEN should be better than RED. Don't ask why!"
assert container.best_quality_properties(['context'], g1, g2) == g1, \
"SEX should be better than SUN. Don't ask why!"
q1 = container.rate_quality(g1, 'color')
q2 = container.rate_quality(g2, 'color')
assert q2 > q1, "GREEN should be greater than RED. Don't ask why!"
container.unregister_quality('context', 'sex')
container.unregister_quality('context', 'sun')
q1 = container.rate_quality(g1)
q2 = container.rate_quality(g2)
assert q2 > q1, "GREEN&SUN should be greater than RED&SEX. Don't ask why!"
g3['context'] = 'sea'
container.unregister_quality('context', 'sea')
q3 = container.rate_quality(g3, 'context')
assert q3 == 0, "Context should be unregistered."
container.unregister_quality('color')
q3 = container.rate_quality(g3, 'color')
assert q3 == 0, "Color should be unregistered."
container.clear_qualities()
q1 = container.rate_quality(g1)
q2 = container.rate_quality(g2)
assert q1 == q2 == 0, "Empty quality container should rate each guess to 0"
def test_quality_transformers(self):
guess_720p = guessit.guess_file_info("2012.2009.720p.BluRay.x264.DTS WiKi.mkv")
guess_1080p = guessit.guess_file_info("2012.2009.1080p.BluRay.x264.MP3 WiKi.mkv")
assert 'audioCodec' in guess_720p, "audioCodec should be present"
assert 'audioCodec' in guess_1080p, "audioCodec should be present"
assert 'screenSize' in guess_720p, "screenSize should be present"
assert 'screenSize' in guess_1080p, "screenSize should be present"
best_quality_guess = best_quality(guess_720p, guess_1080p)
assert guess_1080p == best_quality_guess, "1080p+MP3 is not the best global quality"
best_quality_guess = best_quality_properties(['screenSize'], guess_720p, guess_1080p)
assert guess_1080p == best_quality_guess, "1080p is not the best screenSize"
best_quality_guess = best_quality_properties(['audioCodec'], guess_720p, guess_1080p)
assert guess_720p == best_quality_guess, "DTS is not the best audioCodec"
|