Replace some type(...) checks with isinstance(...)
[cascardo/ipsilon.git] / tests / helpers / http.py
index 97098c8..0643fb1 100755 (executable)
@@ -1,22 +1,6 @@
 #!/usr/bin/python
 #
-# Copyright (C) 2014  Simo Sorce <simo@redhat.com>
-#
-# see file 'COPYING' for use and warranty information
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
+# Copyright (C) 2014 Ipsilon project Contributors, for license see COPYING
 
 from lxml import html
 import requests
@@ -46,7 +30,7 @@ class PageTree(object):
 
     def first_value(self, rule):
         result = self.tree.xpath(rule)
-        if type(result) is list:
+        if isinstance(result, list):
             if len(result) > 0:
                 result = result[0]
             else:
@@ -55,7 +39,7 @@ class PageTree(object):
 
     def all_values(self, rule):
         result = self.tree.xpath(rule)
-        if type(result) is list:
+        if isinstance(result, list):
             return result
         return [result]
 
@@ -137,7 +121,7 @@ class HttpSessions(object):
         return values
 
     def handle_login_form(self, idp, page):
-        if type(page) != PageTree:
+        if not isinstance(page, PageTree):
             raise TypeError("Expected PageTree object")
 
         srv = self.servers[idp]
@@ -167,7 +151,7 @@ class HttpSessions(object):
                 {'headers': headers, 'data': payload}]
 
     def handle_return_form(self, page):
-        if type(page) != PageTree:
+        if not isinstance(page, PageTree):
             raise TypeError("Expected PageTree object")
 
         try:
@@ -193,7 +177,7 @@ class HttpSessions(object):
                 {'headers': headers, 'data': payload}]
 
     def handle_openid_form(self, page):
-        if type(page) != PageTree:
+        if not isinstance(page, PageTree):
             raise TypeError("Expected PageTree object")
 
         if not page.first_value('//title/text()') == \
@@ -223,7 +207,7 @@ class HttpSessions(object):
                 {'headers': headers, 'data': payload}]
 
     def handle_openid_consent_form(self, page):
-        if type(page) != PageTree:
+        if not isinstance(page, PageTree):
             raise TypeError("Expected PageTree object")
 
         try:
@@ -265,7 +249,6 @@ class HttpSessions(object):
         args = {}
 
         while True:
-            # pylint: disable=star-args
             r = self.access(action, url, krb=krb, **args)
             if r.status_code == 303 or r.status_code == 302:
                 if not follow_redirect: