Skip to content

Commit

Permalink
Remove obsolete compat code from integration tests (ansible#81961)
Browse files Browse the repository at this point in the history
Also fix up boilerplate for non .py extension files that contain Python code.
  • Loading branch information
mattclay committed Oct 12, 2023
1 parent 40e4c69 commit 3f60735
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 70 deletions.
23 changes: 8 additions & 15 deletions test/integration/targets/get_url/files/testserver.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
from __future__ import annotations

import http.server
import socketserver
import sys

if __name__ == '__main__':
if sys.version_info[0] >= 3:
import http.server
import socketserver
PORT = int(sys.argv[1])
PORT = int(sys.argv[1])

class Handler(http.server.SimpleHTTPRequestHandler):
pass
class Handler(http.server.SimpleHTTPRequestHandler):
pass

Handler.extensions_map['.json'] = 'application/json'
httpd = socketserver.TCPServer(("", PORT), Handler)
httpd.serve_forever()
else:
import mimetypes
mimetypes.init()
mimetypes.add_type('application/json', '.json')
import SimpleHTTPServer
SimpleHTTPServer.test()
Handler.extensions_map['.json'] = 'application/json'
httpd = socketserver.TCPServer(("", PORT), Handler)
httpd.serve_forever()
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.

from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from __future__ import annotations

ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['stableinterface'],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/python
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from __future__ import annotations

import json

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/python
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from __future__ import annotations

import json

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.

from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from __future__ import annotations

ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['stableinterface'],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/python
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from __future__ import annotations

import json

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/python
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from __future__ import annotations

import json

Expand Down
17 changes: 2 additions & 15 deletions test/integration/targets/setup_rpm_repo/library/create_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

from __future__ import annotations

import subprocess
import sys
import tempfile

from collections import namedtuple
Expand Down Expand Up @@ -67,19 +65,8 @@ def create_repo(arch='x86_64'):

pkgs.append(pkg)

# HACK: EPEL6 version of rpmfluff can't do multi-arch packaging, so we'll just build separately and copy
# the noarch stuff in, since we don't currently care about the repodata for noarch
if sys.version_info[0:2] == (2, 6):
noarch_repo = YumRepoBuild([p for p in pkgs if 'noarch' in p.get_build_archs()])
noarch_repo.make('noarch')

repo = YumRepoBuild([p for p in pkgs if arch in p.get_build_archs()])
repo.make(arch)

subprocess.call("cp {0}/*.rpm {1}".format(noarch_repo.repoDir, repo.repoDir), shell=True)
else:
repo = YumRepoBuild(pkgs)
repo.make(arch, 'noarch')
repo = YumRepoBuild(pkgs)
repo.make(arch, 'noarch')

for pkg in pkgs:
pkg.clean()
Expand Down
23 changes: 8 additions & 15 deletions test/integration/targets/uri/files/testserver.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
from __future__ import annotations

import http.server
import socketserver
import sys

if __name__ == '__main__':
if sys.version_info[0] >= 3:
import http.server
import socketserver
PORT = int(sys.argv[1])
PORT = int(sys.argv[1])

class Handler(http.server.SimpleHTTPRequestHandler):
pass
class Handler(http.server.SimpleHTTPRequestHandler):
pass

Handler.extensions_map['.json'] = 'application/json'
httpd = socketserver.TCPServer(("", PORT), Handler)
httpd.serve_forever()
else:
import mimetypes
mimetypes.init()
mimetypes.add_type('application/json', '.json')
import SimpleHTTPServer
SimpleHTTPServer.test()
Handler.extensions_map['.json'] = 'application/json'
httpd = socketserver.TCPServer(("", PORT), Handler)
httpd.serve_forever()
19 changes: 6 additions & 13 deletions test/integration/targets/wait_for/files/testserver.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
from __future__ import annotations

import http.server
import socketserver
import sys

if __name__ == '__main__':
if sys.version_info[0] >= 3:
import http.server
import socketserver
PORT = int(sys.argv[1])
Handler = http.server.SimpleHTTPRequestHandler
httpd = socketserver.TCPServer(("", PORT), Handler)
httpd.serve_forever()
else:
import mimetypes
mimetypes.init()
mimetypes.add_type('application/json', '.json')
import SimpleHTTPServer
SimpleHTTPServer.test()
PORT = int(sys.argv[1])
Handler = http.server.SimpleHTTPRequestHandler
httpd = socketserver.TCPServer(("", PORT), Handler)
httpd.serve_forever()

0 comments on commit 3f60735

Please sign in to comment.