Skip to content

Instantly share code, notes, and snippets.

@Hyperparticle
Last active June 4, 2017 19:54
Show Gist options
  • Save Hyperparticle/bfec7f3b2ea4a2cc2632f39853dc9dd6 to your computer and use it in GitHub Desktop.
Save Hyperparticle/bfec7f3b2ea4a2cc2632f39853dc9dd6 to your computer and use it in GitHub Desktop.
Robot Framework Python driver example
class LoginLibrary(object):
# Some setup logic
def __init__(self):
self._sut_path = os.path.join(os.path.dirname(__file__),
'..', 'sut', 'login.py')
self._status = ''
def _run_command(self, command, *args):
command = [sys.executable, self._sut_path, command] + list(args)
process = subprocess.Popen(command, universal_newlines=True, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
self._status = process.communicate()[0].strip()
# Robot tests
def create_valid_user(self, username, password):
self._run_command('create', username, password)
def attempt_to_login_with_credentials(self, username, password):
self._run_command('login', username, password)
def status_should_be(self, expected_status):
if expected_status != self._status:
raise AssertionError("Expected status to be '%s' but was '%s'."
% (expected_status, self._status))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment