Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3 compatibility #8

Merged
merged 2 commits into from
Feb 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions flask_analytics/analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def bootstrap(self):
'ENABLED': True
}

args = self.provider_map[provider].__init__.func_code.co_varnames
args = self.provider_map[provider].__init__.__code__.co_varnames
args = [arg for arg in args if arg != 'self']

for arg in args:
Expand Down Expand Up @@ -79,7 +79,7 @@ def build_source(self, config):
if 'ENABLED' in args:
del args['ENABLED']

for key in args:
for key in list(args):
args[key.lower()] = args.pop(key)

instance = self.provider_map[provider](**args)
Expand Down
22 changes: 14 additions & 8 deletions test/test_app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest
import re
from app import app, analytics

class TestAnalytics(unittest.TestCase):
Expand Down Expand Up @@ -41,7 +42,7 @@ def test_none(self):

expected = ""

self.assertEquals(response.data, expected)
self.assertEquals(response.data, expected.encode('utf8'))

def test_disabled(self):

Expand All @@ -51,7 +52,7 @@ def test_disabled(self):

expected = ""

self.assertEquals(response.data, expected)
self.assertEquals(response.data, expected.encode('utf8'))


def test_chartbeat(self):
Expand Down Expand Up @@ -81,7 +82,7 @@ def test_chartbeat(self):
})();
</script>"""

self.assertEquals(response.data, expected)
self.assertEquals(response.data, expected.encode('utf8'))

def test_gosquared(self):

Expand All @@ -98,7 +99,7 @@ def test_gosquared(self):
_gs('ahz1Nahqueorahw');
</script>"""

self.assertEquals(response.data, expected)
self.assertEquals(response.data, expected.encode('utf8'))

def test_piwik(self):

Expand All @@ -119,7 +120,7 @@ def test_piwik(self):
})();
</script>"""

self.assertEquals(response.data, expected)
self.assertEquals(response.data, expected.encode('utf8'))

def test_gauges(self):

Expand All @@ -141,7 +142,7 @@ def test_gauges(self):
})();
</script>"""

self.assertEquals(response.data, expected)
self.assertEquals(response.data, expected.encode('utf8'))

def test_google(self):

Expand All @@ -163,7 +164,7 @@ def test_google(self):

</script>"""

self.assertEquals(response.data, expected)
self.assertEquals(response.data, expected.encode('utf8'))

def test_all(self):

Expand Down Expand Up @@ -238,4 +239,9 @@ def test_all(self):
})();
</script>"""

self.assertEquals(response.data, expected)


response_sections = sorted(re.split('<|>',str(response.data)))
expected_sections = sorted(re.split('<|>',str(expected.encode('utf'))))

self.assertEquals(response_sections, expected_sections)