use renamed test assertions from six

This commit is contained in:
Johnny Robeson 2016-06-20 03:15:30 -04:00
parent 5f4678e3e8
commit 7b66dfec4b
3 changed files with 15 additions and 11 deletions

View file

@ -20,6 +20,7 @@ from __future__ import division, absolute_import, print_function
import os
import shutil
import sqlite3
from six import assertRaisesRegex
from test import _common
from test._common import unittest
@ -298,9 +299,9 @@ class ModelTest(unittest.TestCase):
self.assertNotIn('flex_field', model2)
def test_check_db_fails(self):
with self.assertRaisesRegexp(ValueError, 'no database'):
with assertRaisesRegex(self, ValueError, 'no database'):
dbcore.Model()._check_db()
with self.assertRaisesRegexp(ValueError, 'no id'):
with assertRaisesRegex(self, ValueError, 'no id'):
TestModel1(self.db)._check_db()
dbcore.Model(self.db)._check_db(need_id=False)
@ -312,7 +313,7 @@ class ModelTest(unittest.TestCase):
def test_computed_field(self):
model = TestModelWithGetters()
self.assertEqual(model.aComputedField, 'thing')
with self.assertRaisesRegexp(KeyError, u'computed field .+ deleted'):
with assertRaisesRegex(self, KeyError, u'computed field .+ deleted'):
del model.aComputedField
def test_items(self):
@ -328,7 +329,7 @@ class ModelTest(unittest.TestCase):
model._db
def test_parse_nonstring(self):
with self.assertRaisesRegexp(TypeError, u"must be a string"):
with assertRaisesRegex(self, TypeError, u"must be a string"):
dbcore.Model._parse(None, 42)

View file

@ -23,6 +23,7 @@ import shutil
import tempfile
import datetime
import time
from six import assertCountEqual
from test import _common
from test._common import unittest
@ -268,7 +269,7 @@ class GenreListTestMixin(object):
def test_read_genre_list(self):
mediafile = self._mediafile_fixture('full')
self.assertItemsEqual(mediafile.genres, ['the genre'])
assertCountEqual(self, mediafile.genres, ['the genre'])
def test_write_genre_list(self):
mediafile = self._mediafile_fixture('empty')
@ -276,7 +277,7 @@ class GenreListTestMixin(object):
mediafile.save()
mediafile = MediaFile(mediafile.path)
self.assertItemsEqual(mediafile.genres, [u'one', u'two'])
assertCountEqual(self, mediafile.genres, [u'one', u'two'])
def test_write_genre_list_get_first(self):
mediafile = self._mediafile_fixture('empty')
@ -293,7 +294,7 @@ class GenreListTestMixin(object):
mediafile.save()
mediafile = MediaFile(mediafile.path)
self.assertItemsEqual(mediafile.genres, [u'the genre', u'another'])
assertCountEqual(self, mediafile.genres, [u'the genre', u'another'])
field_extension = MediaField(
@ -949,7 +950,7 @@ class MediaFieldTest(unittest.TestCase):
def test_known_fields(self):
fields = list(ReadWriteTestBase.tag_fields)
fields.extend(('encoder', 'images', 'genres', 'albumtype'))
self.assertItemsEqual(MediaFile.fields(), fields)
assertCountEqual(self, MediaFile.fields(), fields)
def test_fields_in_readable_fields(self):
readable = MediaFile.readable_fields()

View file

@ -4,6 +4,8 @@
from __future__ import division, absolute_import, print_function
from six import assertCountEqual
from test._common import unittest
from test import _common
import json
@ -52,7 +54,7 @@ class WebPluginTest(_common.LibTestCase):
self.assertEqual(response.status_code, 200)
self.assertEqual(len(response.json['items']), 2)
response_titles = [item['title'] for item in response.json['items']]
self.assertItemsEqual(response_titles, [u'title', u'another title'])
assertCountEqual(self, response_titles, [u'title', u'another title'])
def test_get_single_item_not_found(self):
response = self.client.get('/item/3')
@ -80,7 +82,7 @@ class WebPluginTest(_common.LibTestCase):
self.assertEqual(response.status_code, 200)
response_albums = [album['album'] for album in response.json['albums']]
self.assertItemsEqual(response_albums, [u'album', u'another album'])
assertCountEqual(self, response_albums, [u'album', u'another album'])
def test_get_single_album_by_id(self):
response = self.client.get('/album/2')
@ -96,7 +98,7 @@ class WebPluginTest(_common.LibTestCase):
self.assertEqual(response.status_code, 200)
response_albums = [album['album'] for album in response.json['albums']]
self.assertItemsEqual(response_albums, [u'album', u'another album'])
assertCountEqual(self, response_albums, [u'album', u'another album'])
def test_get_album_empty_query(self):
response = self.client.get('/album/query/')