From dd6e56d87c795c86f891e497cd4180c2d790529b Mon Sep 17 00:00:00 2001 From: Rob Cutmore Date: Thu, 15 Oct 2015 17:17:41 -0400 Subject: [PATCH] Add __repr__ method to Field classes Added __repr__ methods to Field classes along with associated tests. [Resolves #19] --- robobrowser/forms/fields.py | 30 +++++++- tests/test_forms.py | 145 ++++++++++++++++++++++++++++++++++++ 2 files changed, 171 insertions(+), 4 deletions(-) diff --git a/robobrowser/forms/fields.py b/robobrowser/forms/fields.py index c6ddeb3..8bfc36a 100644 --- a/robobrowser/forms/fields.py +++ b/robobrowser/forms/fields.py @@ -52,9 +52,14 @@ def __init__(self, parsed): super(Input, self).__init__(parsed) self.value = self._parsed.get('value') + def __repr__(self): + return ''.format(self.name, self.value) + class Submit(Input): - pass + + def __repr__(self): + return ''.format(self.name, self.value) class FileInput(BaseField): @@ -72,6 +77,9 @@ def value(self, value): # in requests. payload_key = 'files' + def __repr__(self): + return ''.format(self.name, self.value) + class MultiOptionField(BaseField): @@ -195,13 +203,21 @@ def __init__(self, parsed): super(Textarea, self).__init__(parsed) self.value = self._parsed.text.rstrip('\r').rstrip('\n') + def __repr__(self): + return '