Skip to content

Commit

Permalink
Store test class on test suite object.
Browse files Browse the repository at this point in the history
This prevents a mysterious bug in which the tests get confused about
which model class is being referenced in the unit tests.
  • Loading branch information
jfinkels committed Sep 11, 2016
1 parent d1bb33a commit 3cc52bc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tests/test_creating.py
Original file line number Diff line number Diff line change
Expand Up @@ -998,9 +998,13 @@ class Tag(self.Base):
id = Column(Integer, primary_key=True)
name = Column(Unicode)

# HACK It seems that if we don't persist the Article class then
# the test sometimes gets confused about which Article class is
# being referenced in requests made in the test methods below.
self.Article = Article
self.Tag = Tag
self.Base.metadata.create_all()
self.manager.create_api(Article, methods=['POST'])
self.manager.create_api(self.Article, methods=['POST'])
# HACK Need to create APIs for these other models because otherwise
# we're not able to create the link URLs to them.
#
Expand Down Expand Up @@ -1033,6 +1037,8 @@ def test_create(self):
}
}
response = self.app.post('/api/article', data=dumps(data))
print(dir(self.Article))
print(response.data)
assert response.status_code == 201
document = loads(response.data)
article = document['data']
Expand Down

0 comments on commit 3cc52bc

Please sign in to comment.