Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
django-taggit
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
162f0857
authored
Aug 10, 2014
by
Florian Apolloner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test fixes and more 1.7 fixes.
parent
94485073
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
10 deletions
+11
-10
taggit/managers.py
+1
-0
tests/tests.py
+10
-10
No files found.
taggit/managers.py
View file @
162f0857
...
...
@@ -301,6 +301,7 @@ class TaggableManager(RelatedField, Field):
self
.
use_gfk
=
(
self
.
through
is
None
or
issubclass
(
self
.
through
,
GenericTaggedItemBase
)
)
if
not
self
.
rel
.
to
:
self
.
rel
.
to
=
self
.
through
.
_meta
.
get_field
(
"tag"
)
.
rel
.
to
self
.
related
=
RelatedObject
(
self
.
through
,
cls
,
self
)
if
self
.
use_gfk
:
...
...
tests/tests.py
View file @
162f0857
...
...
@@ -22,8 +22,8 @@ from taggit.models import Tag, TaggedItem
from
.forms
import
(
FoodForm
,
DirectFoodForm
,
CustomPKFoodForm
,
OfficialFoodForm
)
from
.models
import
(
Food
,
Pet
,
HousePet
,
DirectFood
,
DirectPet
,
DirectHousePet
,
Tagged
Pet
,
CustomPKFood
,
CustomPKPet
,
CustomPKHousePet
,
TaggedCustomPK
Pet
,
OfficialFood
,
OfficialPet
,
OfficialHousePet
,
DirectHousePet
,
Tagged
Food
,
CustomPKFood
,
CustomPKPet
,
CustomPKHousePet
,
TaggedCustomPK
Food
,
OfficialFood
,
OfficialPet
,
OfficialHousePet
,
OfficialThroughModel
,
OfficialTag
,
Photo
,
Movie
,
Article
,
CustomManager
)
from
taggit.utils
import
parse_tags
,
edit_string_for_tags
...
...
@@ -298,13 +298,12 @@ class TaggableManagerTestCase(BaseTaggingTestCase):
)
def
test_taggeditem_unicode
(
self
):
ross
=
self
.
pet_model
.
objects
.
create
(
name
=
"ross"
)
# I keep Ross Perot for a pet, what's it to you?
ross
.
tags
.
add
(
"president"
)
apple
=
self
.
food_model
.
objects
.
create
(
name
=
"apple"
)
apple
.
tags
.
add
(
"juicy"
)
self
.
assertEqual
(
force_text
(
self
.
taggeditem_model
.
objects
.
all
()[
0
]),
"
ross tagged with president
"
"
apple tagged with juicy
"
)
def
test_abstract_subclasses
(
self
):
...
...
@@ -364,13 +363,13 @@ class TaggableManagerDirectTestCase(TaggableManagerTestCase):
food_model
=
DirectFood
pet_model
=
DirectPet
housepet_model
=
DirectHousePet
taggeditem_model
=
Tagged
Pet
taggeditem_model
=
Tagged
Food
class
TaggableManagerCustomPKTestCase
(
TaggableManagerTestCase
):
food_model
=
CustomPKFood
pet_model
=
CustomPKPet
housepet_model
=
CustomPKHousePet
taggeditem_model
=
TaggedCustomPK
Pet
taggeditem_model
=
TaggedCustomPK
Food
def
test_require_pk
(
self
):
# TODO with a charfield pk, pk is never None, so taggit has no way to
...
...
@@ -557,10 +556,11 @@ class TagStringParseTestCase(UnitTestCase):
@skipIf
(
django
.
VERSION
<
(
1
,
7
),
"not relevant for Django < 1.7"
)
class
DeconstructTestCase
(
UnitTestCase
):
def
test_deconstruct_kwargs_kept
(
self
):
instance
=
TaggableManager
(
through
=
OfficialThroughModel
)
instance
=
TaggableManager
(
through
=
OfficialThroughModel
,
to
=
'dummy.To'
)
name
,
path
,
args
,
kwargs
=
instance
.
deconstruct
()
new_instance
=
TaggableManager
(
*
args
,
**
kwargs
)
self
.
assertEqual
(
instance
.
rel
.
through
,
new_instance
.
rel
.
through
)
self
.
assertEqual
(
'tests.OfficialThroughModel'
,
new_instance
.
rel
.
through
)
self
.
assertEqual
(
'dummy.To'
,
new_instance
.
rel
.
to
)
@skipUnless
(
django
.
VERSION
<
(
1
,
7
),
"test only applies to 1.6 and below"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment