<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Problem with AGP Python Toolbox executing Unittest in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/problem-with-agp-python-toolbox-executing-unittest/m-p/1343183#M74595</link>
    <description>&lt;P&gt;the &lt;EM&gt;&lt;SPAN class=""&gt;class&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;&amp;nbsp;constructor&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/EM&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;unittest.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;TextTestRunner has an argument stream, which can be initialized to sys.stdout. In this case the problem with failing tools does not exist.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 30 Oct 2023 08:42:54 GMT</pubDate>
    <dc:creator>BernhardEhrminger</dc:creator>
    <dc:date>2023-10-30T08:42:54Z</dc:date>
    <item>
      <title>Problem with AGP Python Toolbox executing Unittest</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/problem-with-agp-python-toolbox-executing-unittest/m-p/1340800#M74324</link>
      <description>&lt;P&gt;In Module FileCount.py I have a simple Python Unittest, which tests that the number of files in current directory is greater than zero, so the test should never fail.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import unittest
import pathlib


class Test(unittest.TestCase):

    def setUp(self):
        pass

    def tearDown(self):
        pass

    def test_file_count(self):
        self.assertGreater(
            len(list(pathlib.Path().cwd().glob('*'))), 0)
        pass&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Python Tool-Class referencing the Unittest is like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;class DemoUnittest(object):

    def __init__(self):
        """Define the tool (tool name is the name of the class)."""
        self.label = "Demo_Unittest"
        self.description = "Execute a Unittest"
        self.canRunInBackground = True

    def getParameterInfo(self):
        """Define parameter definitions"""
        params = None
        return params

    def isLicensed(self):
        """Set whether tool is licensed to execute."""
        return True

    def updateParameters(self, parameters):
        """Modify the values and properties of parameters before internal validation is performed.  This method is called whenever a parameter has been changed."""
        return

    def updateMessages(self, parameters):
        """Modify the messages created by internal validation for each tool parameter. This method is called after internal validation."""
        return

    def execute(self, parameters, messages):
        """The source code of the tool."""
        try:
            self.result = unittest.TextTestRunner().run(
                unittest.TestLoader().loadTestsFromModule(
                    module = FileCount))
            arcpy.AddMessage(self.result)
        except Exception as e:
            arcpy.AddMessage(str(e))
        return True

    def postExecute(self, parameters):
        arcpy.AddMessage(self.result)
        """This method takes place after outputs are processed and added to the display."""
        return&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When running the Python Tool in ArcGIS Pro I get the following result:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2023-10-24 10_21_32-Clipboard.png" style="width: 537px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/83770iE021B360FD3522EE/image-size/large?v=v2&amp;amp;px=999" role="button" title="2023-10-24 10_21_32-Clipboard.png" alt="2023-10-24 10_21_32-Clipboard.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;So from the screen dump above, I conclude the Unittest performed as expected (OK).&lt;/P&gt;&lt;P&gt;But why is ArcGIS Pro telling me erroneously&amp;nbsp; "Failed to execute (DemoUnittest)"?&lt;/P&gt;&lt;P&gt;Thank You for your attention.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Oct 2023 08:48:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/problem-with-agp-python-toolbox-executing-unittest/m-p/1340800#M74324</guid>
      <dc:creator>BernhardEhrminger</dc:creator>
      <dc:date>2023-10-24T08:48:11Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with AGP Python Toolbox executing Unittest</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/problem-with-agp-python-toolbox-executing-unittest/m-p/1341210#M74382</link>
      <description>&lt;P&gt;The default output stream for&amp;nbsp;&lt;A href="https://docs.python.org/3/library/unittest.html#unittest.TextTestRunner" target="_self"&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;unittest.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;A href="https://docs.python.org/3/library/unittest.html#unittest.TextTestRunner" target="_self"&gt;TextTestRunner&lt;/A&gt; is sys.stderr and&amp;nbsp;I don't know and haven't tested, but&amp;nbsp; perhaps ArcGIS notices this and assumes there's been an error?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2023 05:37:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/problem-with-agp-python-toolbox-executing-unittest/m-p/1341210#M74382</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2023-10-26T05:37:25Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with AGP Python Toolbox executing Unittest</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/problem-with-agp-python-toolbox-executing-unittest/m-p/1341251#M74387</link>
      <description>&lt;P&gt;thank you Luke, the situation is like you pointed out.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2023 08:26:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/problem-with-agp-python-toolbox-executing-unittest/m-p/1341251#M74387</guid>
      <dc:creator>BernhardEhrminger</dc:creator>
      <dc:date>2023-10-25T08:26:59Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with AGP Python Toolbox executing Unittest</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/problem-with-agp-python-toolbox-executing-unittest/m-p/1343183#M74595</link>
      <description>&lt;P&gt;the &lt;EM&gt;&lt;SPAN class=""&gt;class&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;&amp;nbsp;constructor&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/EM&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;unittest.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;TextTestRunner has an argument stream, which can be initialized to sys.stdout. In this case the problem with failing tools does not exist.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Oct 2023 08:42:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/problem-with-agp-python-toolbox-executing-unittest/m-p/1343183#M74595</guid>
      <dc:creator>BernhardEhrminger</dc:creator>
      <dc:date>2023-10-30T08:42:54Z</dc:date>
    </item>
  </channel>
</rss>

