Skip to content

Commit

Permalink
Fixed functional tests code after py3k support
Browse files Browse the repository at this point in the history
  • Loading branch information
lins05 committed Jan 17, 2016
1 parent 71a2c40 commit 411c79f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ slackbot_settings.py
/build
/dist
/*.egg-info
.cache
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[pytest]
addopts = -s -v --doctest-modules --ignore=build --ignore=dist --ignore=slackbot.egg-info --ignore=setup.py
addopts = -s -v --ignore=build --ignore=dist --ignore=slackbot.egg-info --ignore=setup.py
5 changes: 3 additions & 2 deletions slackbot/slackclient.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# -*- coding: utf8 -*-
#coding: UTF-8

from __future__ import print_function, absolute_import
import os
import json
import logging
import time
import slacker
from six import iteritems

from websocket import (
create_connection, WebSocketException, WebSocketConnectionClosedException
Expand Down Expand Up @@ -124,7 +125,7 @@ def get_channel(self, channel_id):
return Channel(self, self.channels[channel_id])

def find_user_by_name(self, username):
for userid, user in self.users.iteritems():
for userid, user in iteritems(self.users):
if user['name'] == username:
return userid

Expand Down
14 changes: 7 additions & 7 deletions tests/functional/driver.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import thread
import threading
import json
import re
import time
import slacker
import websocket
from six.moves import _thread, range


class Driver(object):
Expand Down Expand Up @@ -44,7 +44,7 @@ def wait_for_bot_offline(self):
self._wait_for_bot_presense(False)

def _wait_for_bot_presense(self, online):
for _ in xrange(10):
for _ in range(10):
time.sleep(2)
if online and self._is_testbot_online():
break
Expand Down Expand Up @@ -92,7 +92,7 @@ def ensure_only_specificmessage_from_bot(self, match, wait=5, tosender=False):
else:
match = r'^%s$' % match

for _ in xrange(wait):
for _ in range(wait):
time.sleep(1)
with self._events_lock:
for event in self.events:
Expand All @@ -101,7 +101,7 @@ def ensure_only_specificmessage_from_bot(self, match, wait=5, tosender=False):
'expected to get message matching "%s", but got message "%s"' % (match, event['text']))

def ensure_no_channel_reply_from_bot(self, wait=5):
for _ in xrange(wait):
for _ in range(wait):
time.sleep(1)
with self._events_lock:
for event in self.events:
Expand All @@ -110,7 +110,7 @@ def ensure_no_channel_reply_from_bot(self, wait=5):
'expected to get nothing, but got message "%s"' % event['text'])

def wait_for_file_uploaded(self, name, maxwait=60):
for _ in xrange(maxwait):
for _ in range(maxwait):
time.sleep(1)
if self._has_uploaded_file_rtm(name):
break
Expand All @@ -122,7 +122,7 @@ def _send_message_to_bot(self, channel, msg):
self.slacker.chat.post_message(channel, msg, username=self.driver_username)

def _wait_for_bot_message(self, channel, match, maxwait=60, tosender=True):
for _ in xrange(maxwait):
for _ in range(maxwait):
time.sleep(1)
if self._has_got_message_rtm(channel, match, tosender):
break
Expand Down Expand Up @@ -169,7 +169,7 @@ def _rtm_connect(self):

self._websocket = websocket.create_connection(r['url'])
self._websocket.sock.setblocking(0)
thread.start_new_thread(self._rtm_read_forever, tuple())
_thread.start_new_thread(self._rtm_read_forever, tuple())

def _websocket_safe_read(self):
"""Returns data if available, otherwise ''. Newlines indicate multiple messages """
Expand Down

0 comments on commit 411c79f

Please sign in to comment.