Skip to content

Commit

Permalink
Fix test in python 3
Browse files Browse the repository at this point in the history
  • Loading branch information
goinnn committed Nov 2, 2013
1 parent 884f039 commit bf8763a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion test_project/test_app/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.

import sys

PY3 = sys.version_info[0] == 3

from django.conf import settings
from django.core.urlresolvers import reverse
from django.test import TestCase
Expand Down Expand Up @@ -49,7 +53,10 @@ def _test_check_report_csv(self, url, report_format='csv'):
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
if report_format == 'csv':
num_lines = len([line for line in response.content.split('\n') if line])
content = response.content
if PY3:
content = content.decode(settings.DEFAULT_CHARSET)
num_lines = len([line for line in content.split('\n') if line])
self.assertEqual(num_lines - 1, Person.objects.all().count())
return response

Expand Down

0 comments on commit bf8763a

Please sign in to comment.