Skip to content

Add support for Python 3 #6

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

Merged
merged 5 commits into from
Jan 27, 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
7 changes: 3 additions & 4 deletions QuickStart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,9 @@ installing additional docutils__ module::

pip install docutils

Notice that at the time of this writing Python 3 is not yet officially
supported. See the aforementioned `installation instructions`_ for information
about an unofficial Python 3 port and the latest status of Python 3 support in
general.
Notice that Robot Framework 3.0 is the first Robot Framework version to support
Python 3. See the aforementioned `installation instructions`_ for information
about Python 2 vs Python 3.

.. _`Robot Framework installation instructions`:
https://github.com/robotframework/robotframework/blob/master/INSTALL.rst
Expand Down
3 changes: 2 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ through it and look at the examples, but you can also use the guide as
an executable demo.

The guide itself is in `<QuickStart.rst>`_ file. It replaces the old version
still available on the `old project pages`__.
still available on the `old project pages`__. Robot Framework 3.0 introduced
python 3 support. This guide executes under Python 2.7, 3.3, and newer.

Copyright © Nokia Solutions and Networks. Licensed under the
`Creative Commons Attribution 3.0 Unported`__ license.
Expand Down
2 changes: 1 addition & 1 deletion lib/LoginLibrary.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ def status_should_be(self, expected_status):

def _run_command(self, command, *args):
command = [sys.executable, self._sut_path, command] + list(args)
process = subprocess.Popen(command, stdout=subprocess.PIPE,
process = subprocess.Popen(command, universal_newlines=True, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
self._status = process.communicate()[0].strip()
14 changes: 8 additions & 6 deletions sut/login.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env python

from __future__ import print_function

import os.path
import sys
import tempfile
Expand Down Expand Up @@ -27,7 +29,7 @@ def _read_users(self, path):
def create_user(self, username, password):
try:
user = User(username, password)
except ValueError, err:
except ValueError as err:
return 'Creating user failed: %s' % err
self.users[user.username] = user
return 'SUCCESS'
Expand All @@ -47,7 +49,7 @@ def change_password(self, username, old_pwd, new_pwd):
if not self._is_valid_user(username, old_pwd):
raise ValueError('Access Denied')
self.users[username].password = new_pwd
except ValueError, err:
except ValueError as err:
return 'Changing password failed: %s' % err
else:
return 'SUCCESS'
Expand Down Expand Up @@ -104,21 +106,21 @@ def _validate_password_chars(self, password):

def login(username, password):
with UserDataBase() as db:
print db.login(username, password)
print(db.login(username, password))


def create_user(username, password):
with UserDataBase() as db:
print db.create_user(username, password)
print(db.create_user(username, password))


def change_password(username, old_pwd, new_pwd):
with UserDataBase() as db:
print db.change_password(username, old_pwd, new_pwd)
print(db.change_password(username, old_pwd, new_pwd))


def help():
print ('Usage: %s { create | login | change-password | help }'
print('Usage: %s { create | login | change-password | help }'
% os.path.basename(sys.argv[0]))


Expand Down