Skip to content

Commit

Permalink
[fc] Repository: plone.app.testing
Browse files Browse the repository at this point in the history
Branch: refs/heads/4.2.x
Date: 2018-10-04T12:42:29+02:00
Author: Joni Orponen (Rotonen) <joni.orponen@gmail.com>
Commit: plone/plone.app.testing@04e7548

Fix now-false doctests on layer setup port selection.

Files changed:
M CHANGES.rst
M plone/app/testing/layers.rst
Repository: plone.app.testing

Branch: refs/heads/4.2.x
Date: 2018-10-04T22:54:09+02:00
Author: Gil Forcada Codinachs (gforcada) <gil.gnome@gmail.com>
Commit: plone/plone.app.testing@532790e

Merge pull request #53 from plone/free-ports-4.2.x

Fix now-false doctests on layer setup port selection.

Files changed:
M CHANGES.rst
M plone/app/testing/layers.rst
  • Loading branch information
gforcada committed Oct 4, 2018
1 parent 4f7cc88 commit 6d75b95
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions last_commit.txt
Original file line number Diff line number Diff line change
@@ -1,36 +1,34 @@
Repository: plone.testing
Repository: plone.app.testing


Branch: refs/heads/4.1.x
Date: 2018-10-04T12:31:03+02:00
Branch: refs/heads/4.2.x
Date: 2018-10-04T12:42:29+02:00
Author: Joni Orponen (Rotonen) <joni.orponen@gmail.com>
Commit: https://github.com/plone/plone.testing/commit/561f637ab793562c52a88357817567f2ac0c1477
Commit: https://github.com/plone/plone.app.testing/commit/04e7548844a69eadfd33bb7e06001a9c7b8ac3cd

Enable picking a free port for ZServer layers automatically.
Fix now-false doctests on layer setup port selection.

Files changed:
M CHANGES.rst
M src/plone/testing/z2.py
M src/plone/testing/z2.rst
M plone/app/testing/layers.rst

b'diff --git a/CHANGES.rst b/CHANGES.rst\nindex 14e20eb..a251111 100644\n--- a/CHANGES.rst\n+++ b/CHANGES.rst\n@@ -6,7 +6,9 @@ Changelog\n \n Breaking changes:\n \n-- *add item here*\n+- Default to picking a dynamical port for ZServer layers instead of a static\n+ default port.\n+ [Rotonen]\n \n New features:\n \ndiff --git a/src/plone/testing/z2.py b/src/plone/testing/z2.py\nindex d661ad7..128b6cc 100644\n--- a/src/plone/testing/z2.py\n+++ b/src/plone/testing/z2.py\n@@ -969,8 +969,10 @@ class ZServer(Layer):\n \n defaultBases = (STARTUP,)\n \n- host = os.environ.get(\'ZSERVER_HOST\', \'localhost\')\n- port = int(os.environ.get(\'ZSERVER_PORT\', 55001))\n+ # Default to \'bindall\' (marked by an empty string) from os.socket\n+ host = os.environ.get(\'ZSERVER_HOST\', \'\')\n+ # Default to letting the OS allocate us a free port (marked by 0)\n+ port = int(os.environ.get(\'ZSERVER_PORT\', 0))\n timeout = 5.0\n log = None\n \n@@ -1033,6 +1035,17 @@ def setUpServer(self):\n \n self.zserver = server\n \n+ # If we dynamically set the host/port, we want to reset it to localhost\n+ # Otherwise this will depend on, for example, the local network setup\n+ if self.host in (\'\', \'0.0.0.0\', \'127.0.0.1\', ):\n+ self.zserver.server_name = \'localhost\'\n+\n+ # Refresh the hostname and port in case we dynamically picked them\n+ self.host = self.zserver.server_name\n+ self[\'host\'] = self.host\n+ self.port = self.zserver.server_port\n+ self[\'port\'] = self.port\n+\n def tearDownServer(self):\n """Close the ZServer socket\n """\n@@ -1080,8 +1093,10 @@ class FTPServer(ZServer):\n \n defaultBases = (STARTUP,)\n \n- host = os.environ.get(\'FTPSERVER_HOST\', \'localhost\')\n- port = int(os.environ.get(\'FTPSERVER_PORT\', 55002))\n+ # Default to \'bindall\' (marked by an empty string) from os.socket\n+ host = os.environ.get(\'FTPSERVER_HOST\', \'\')\n+ # Default to letting the OS allocate us a free port (marked by 0)\n+ port = int(os.environ.get(\'FTPSERVER_PORT\', 0))\n threads = 1\n timeout = 5.0\n log = None\n@@ -1106,6 +1121,20 @@ def setUpServer(self):\n port=self.port,\n logger_object=zopeLog)\n \n+\n+ # Refresh the hostname and port in case we dynamically picked them\n+ self.host, self.port = self.ftpServer.socket.getsockname()\n+\n+ # If we dynamically set the host/port, we want to reset it to localhost\n+ # Otherwise this will depend on, for example, the local network setup\n+ if self.host in (\'\', \'0.0.0.0\', \'127.0.0.1\', ):\n+ self.host = \'localhost\'\n+ self.ftpServer.hostname = \'localhost\'\n+ self.ftpServer.ip = \'127.0.0.1\'\n+\n+ self[\'host\'] = self.host\n+ self[\'port\'] = self.port\n+\n def tearDownServer(self):\n """Close the FTPServer socket\n """\ndiff --git a/src/plone/testing/z2.rst b/src/plone/testing/z2.rst\nindex 6479e6a..f0fb4ac 100644\n--- a/src/plone/testing/z2.rst\n+++ b/src/plone/testing/z2.rst\n@@ -465,13 +465,7 @@ The ``ZSERVER`` layer provides a ``FunctionalTesting`` layer that has ``ZSERVER_\n After layer setup, the resources ``host`` and ``port`` are available, and indicate where Zope is running.::\n \n >>> host = z2.ZSERVER[\'host\']\n- >>> host\n- \'localhost\'\n-\n >>> port = z2.ZSERVER[\'port\']\n- >>> import os\n- >>> port == int(os.environ.get(\'ZSERVER_PORT\', 55001))\n- True\n \n Let\'s now simulate a test.\n Test setup does nothing beyond what the base layers do.::\n@@ -569,13 +563,7 @@ The ``FTP_SERVER`` layer is based on ``FTP_SERVER_FIXTURE``, using the ``Functio\n After layer setup, the resources ``host`` and ``port`` are available, and indicate where Zope is running.::\n \n >>> host = z2.FTP_SERVER[\'host\']\n- >>> host\n- \'localhost\'\n-\n >>> port = z2.FTP_SERVER[\'port\']\n- >>> import os\n- >>> port == int(os.environ.get(\'FTPSERVER_PORT\', 55002))\n- True\n \n Let\'s now simulate a test.\n Test setup does nothing beyond what the base layers do.::\n'
b"diff --git a/CHANGES.rst b/CHANGES.rst\nindex 6e5b1fa..511bfb8 100644\n--- a/CHANGES.rst\n+++ b/CHANGES.rst\n@@ -14,7 +14,8 @@ New features:\n \n Bug fixes:\n \n-- *add item here*\n+- Amended the doctests to work with automatical layer port picking from plone.testing.\n+ [Rotonen]\n \n \n 4.2.6 (2017-05-09)\ndiff --git a/plone/app/testing/layers.rst b/plone/app/testing/layers.rst\nindex 17b919d..62d9171 100644\n--- a/plone/app/testing/layers.rst\n+++ b/plone/app/testing/layers.rst\n@@ -300,8 +300,7 @@ indicate where Zope is running.\n \n >>> port = layers.PLONE_ZSERVER['port']\n >>> import os\n- >>> port == int(os.environ.get('ZSERVER_PORT', 55001))\n- True\n+ >>> # port == int(os.environ.get('ZSERVER_PORT', 0))\n \n Let's now simulate a test. Test setup does nothing beyond what the base layers\n do.\n@@ -407,8 +406,7 @@ indicate where Zope is running.\n \n >>> port = layers.PLONE_FTP_SERVER['port']\n >>> import os\n- >>> port == int(os.environ.get('FTPSERVER_PORT', 55002))\n- True\n+ >>> # port == int(os.environ.get('FTPSERVER_PORT', 0))\n \n Let's now simulate a test. Test setup does nothing beyond what the base layers\n do.\n"

Repository: plone.testing
Repository: plone.app.testing


Branch: refs/heads/4.1.x
Date: 2018-10-04T22:53:50+02:00
Branch: refs/heads/4.2.x
Date: 2018-10-04T22:54:09+02:00
Author: Gil Forcada Codinachs (gforcada) <gil.gnome@gmail.com>
Commit: https://github.com/plone/plone.testing/commit/0900de68325c59e2b909445dacd695ae83e89299
Commit: https://github.com/plone/plone.app.testing/commit/532790e23dcac78bbdd5d028753a03e1be7b75ea

Merge pull request #56 from plone/free-ports-4.1
Merge pull request #53 from plone/free-ports-4.2.x

Enable picking a free port for ZServer layers automatically.
Fix now-false doctests on layer setup port selection.

Files changed:
M CHANGES.rst
M src/plone/testing/z2.py
M src/plone/testing/z2.rst
M plone/app/testing/layers.rst

b'diff --git a/CHANGES.rst b/CHANGES.rst\nindex 14e20eb..a251111 100644\n--- a/CHANGES.rst\n+++ b/CHANGES.rst\n@@ -6,7 +6,9 @@ Changelog\n \n Breaking changes:\n \n-- *add item here*\n+- Default to picking a dynamical port for ZServer layers instead of a static\n+ default port.\n+ [Rotonen]\n \n New features:\n \ndiff --git a/src/plone/testing/z2.py b/src/plone/testing/z2.py\nindex d661ad7..128b6cc 100644\n--- a/src/plone/testing/z2.py\n+++ b/src/plone/testing/z2.py\n@@ -969,8 +969,10 @@ class ZServer(Layer):\n \n defaultBases = (STARTUP,)\n \n- host = os.environ.get(\'ZSERVER_HOST\', \'localhost\')\n- port = int(os.environ.get(\'ZSERVER_PORT\', 55001))\n+ # Default to \'bindall\' (marked by an empty string) from os.socket\n+ host = os.environ.get(\'ZSERVER_HOST\', \'\')\n+ # Default to letting the OS allocate us a free port (marked by 0)\n+ port = int(os.environ.get(\'ZSERVER_PORT\', 0))\n timeout = 5.0\n log = None\n \n@@ -1033,6 +1035,17 @@ def setUpServer(self):\n \n self.zserver = server\n \n+ # If we dynamically set the host/port, we want to reset it to localhost\n+ # Otherwise this will depend on, for example, the local network setup\n+ if self.host in (\'\', \'0.0.0.0\', \'127.0.0.1\', ):\n+ self.zserver.server_name = \'localhost\'\n+\n+ # Refresh the hostname and port in case we dynamically picked them\n+ self.host = self.zserver.server_name\n+ self[\'host\'] = self.host\n+ self.port = self.zserver.server_port\n+ self[\'port\'] = self.port\n+\n def tearDownServer(self):\n """Close the ZServer socket\n """\n@@ -1080,8 +1093,10 @@ class FTPServer(ZServer):\n \n defaultBases = (STARTUP,)\n \n- host = os.environ.get(\'FTPSERVER_HOST\', \'localhost\')\n- port = int(os.environ.get(\'FTPSERVER_PORT\', 55002))\n+ # Default to \'bindall\' (marked by an empty string) from os.socket\n+ host = os.environ.get(\'FTPSERVER_HOST\', \'\')\n+ # Default to letting the OS allocate us a free port (marked by 0)\n+ port = int(os.environ.get(\'FTPSERVER_PORT\', 0))\n threads = 1\n timeout = 5.0\n log = None\n@@ -1106,6 +1121,20 @@ def setUpServer(self):\n port=self.port,\n logger_object=zopeLog)\n \n+\n+ # Refresh the hostname and port in case we dynamically picked them\n+ self.host, self.port = self.ftpServer.socket.getsockname()\n+\n+ # If we dynamically set the host/port, we want to reset it to localhost\n+ # Otherwise this will depend on, for example, the local network setup\n+ if self.host in (\'\', \'0.0.0.0\', \'127.0.0.1\', ):\n+ self.host = \'localhost\'\n+ self.ftpServer.hostname = \'localhost\'\n+ self.ftpServer.ip = \'127.0.0.1\'\n+\n+ self[\'host\'] = self.host\n+ self[\'port\'] = self.port\n+\n def tearDownServer(self):\n """Close the FTPServer socket\n """\ndiff --git a/src/plone/testing/z2.rst b/src/plone/testing/z2.rst\nindex 6479e6a..f0fb4ac 100644\n--- a/src/plone/testing/z2.rst\n+++ b/src/plone/testing/z2.rst\n@@ -465,13 +465,7 @@ The ``ZSERVER`` layer provides a ``FunctionalTesting`` layer that has ``ZSERVER_\n After layer setup, the resources ``host`` and ``port`` are available, and indicate where Zope is running.::\n \n >>> host = z2.ZSERVER[\'host\']\n- >>> host\n- \'localhost\'\n-\n >>> port = z2.ZSERVER[\'port\']\n- >>> import os\n- >>> port == int(os.environ.get(\'ZSERVER_PORT\', 55001))\n- True\n \n Let\'s now simulate a test.\n Test setup does nothing beyond what the base layers do.::\n@@ -569,13 +563,7 @@ The ``FTP_SERVER`` layer is based on ``FTP_SERVER_FIXTURE``, using the ``Functio\n After layer setup, the resources ``host`` and ``port`` are available, and indicate where Zope is running.::\n \n >>> host = z2.FTP_SERVER[\'host\']\n- >>> host\n- \'localhost\'\n-\n >>> port = z2.FTP_SERVER[\'port\']\n- >>> import os\n- >>> port == int(os.environ.get(\'FTPSERVER_PORT\', 55002))\n- True\n \n Let\'s now simulate a test.\n Test setup does nothing beyond what the base layers do.::\n'
b"diff --git a/CHANGES.rst b/CHANGES.rst\nindex 6e5b1fa..511bfb8 100644\n--- a/CHANGES.rst\n+++ b/CHANGES.rst\n@@ -14,7 +14,8 @@ New features:\n \n Bug fixes:\n \n-- *add item here*\n+- Amended the doctests to work with automatical layer port picking from plone.testing.\n+ [Rotonen]\n \n \n 4.2.6 (2017-05-09)\ndiff --git a/plone/app/testing/layers.rst b/plone/app/testing/layers.rst\nindex 17b919d..62d9171 100644\n--- a/plone/app/testing/layers.rst\n+++ b/plone/app/testing/layers.rst\n@@ -300,8 +300,7 @@ indicate where Zope is running.\n \n >>> port = layers.PLONE_ZSERVER['port']\n >>> import os\n- >>> port == int(os.environ.get('ZSERVER_PORT', 55001))\n- True\n+ >>> # port == int(os.environ.get('ZSERVER_PORT', 0))\n \n Let's now simulate a test. Test setup does nothing beyond what the base layers\n do.\n@@ -407,8 +406,7 @@ indicate where Zope is running.\n \n >>> port = layers.PLONE_FTP_SERVER['port']\n >>> import os\n- >>> port == int(os.environ.get('FTPSERVER_PORT', 55002))\n- True\n+ >>> # port == int(os.environ.get('FTPSERVER_PORT', 0))\n \n Let's now simulate a test. Test setup does nothing beyond what the base layers\n do.\n"

0 comments on commit 6d75b95

Please sign in to comment.