← Back to team overview

kubuntu-council team mailing list archive

Re: [Merge] ~waveform/ubuntu-manual-tests:doctest into ubuntu-manual-tests:master

 

Thanks! Have responded to comments, will append a patch commit in a bit.

Diff comments:

> diff --git a/definitions/basic_installation.xml b/definitions/basic_installation.xml
> new file mode 100644
> index 0000000..413dd32
> --- /dev/null
> +++ b/definitions/basic_installation.xml
> @@ -0,0 +1,129 @@
> +<ut:configuration xmlns:ut="urn:com:ubuntu:tests">
> +  <ut:template>
> +    <p><em>Proceed in your native language if you wish. Instructions
> +      will remain in English.</em></p>
> +    <dl>
> +      <ut:tests />
> +    </dl>
> +    <p>If <strong>all</strong> actions produce the expected results listed,
> +      please <a href="results#add_result">submit</a> a 'passed' result.</p>
> +    <p>If <strong>any</strong> action fails, or produces an unexpected result,
> +      please <a href="results#add_result">submit</a> a 'failed' result and <a
> +      href="../../buginstructions">file a bug</a>. Please be sure to include
> +      the bug number when you <a href="results#add_result">submit</a> your
> +      result.</p>
> +  </ut:template>
> +
> +  <ut:test id="start">
> +    <dt>Boot up the image</dt>
> +        <dd>The system boots properly and loads the installer displaying the Welcome dialog with language selection and 'Try FAMILY' and 'Install FAMILY' buttons</dd>
> +    <dt>Click on the release notes hyperlink to confirm that a browser launches and you are taken to the release notes web page.</dt>
> +    <dt>Click on the Install FAMILY button</dt>
> +        <dd>The 'Keyboard Layout' screen appears</dd>
> +        <dd>The proposed keyboard corresponds with your keyboard</dd>
> +    <dt>Select your keyboard layout and click on continue</dt>
> +        <dd>The 'Updates and other software' screen is displayed</dd>
> +    <dt>On the screen 'Updates and other software', note the availability of the following components</dt>
> +        <dd>Available options should represent the state of your system accurately</dd>
> +        <dd>
> +            <ul>
> +                <li>(If network is available) Download updates while installing FAMILY</li>
> +                <li>(If on a 'laptop') Is plugged to a power source</li>
> +                <li>Install third-party software ... option available</li>
> +            </ul>
> +        </dd>
> +    <dt>Click on the continue button</dt>
> +        <dd>The 'Installation type' screen is displayed</dd>
> +  </ut:test>
> +
> +  <ut:test id="entire-disk">
> +    <dt>Select Erase disk and install FAMILY</dt>
> +        <dd>Installation screen expands to include encryption and LVM options</dd>
> +    <dt>Click on the continue button (if there is only one hard disk in the system, the button should read 'Install now')</dt>
> +        <dd>Write changes dialogue appears</dd>
> +    <dt>Click continue</dt>
> +        <dd>If there is only one hard disk, the installer skips to the "Where are you?' screen. Otherwise, the 'Installation type' screen is displayed</dd>
> +    <dt>If there is only one hard disk, skip to step 12 (On the 'Where are you?' screen...). Otherwise, on the 'Installation type' page, select a drive in the 'Select drive' list.</dt>
> +        <dd>Verify that the selected drive corresponds to the drive on the chart</dd>
> +    <dt>Verify that the full drive space is allocated</dt>
> +        <dd>Full drive space is allocated for installation</dd>
> +    <dt>Click on the Install Now button</dt>
> +        <dd>The 'Where are you?' screen is displayed</dd>
> +  </ut:test>
> +
> +  <ut:test id="auto-resize">
> +    <dt>Select Install FAMILY XX.XX alongside SYSTEM YY </dt>
> +        <dd>(SYSTEM YY is the name of the system already installed on disk (FAMILY 12.04, Windows 7, ...)</dd>
> +    <dt>Click on Continue</dt>
> +        <dd>The Screen Install FAMILY XX.XX alongside SYSTEM YY appears</dd>
> +    <dt>Note the drive selected on the Select drive list and the bar state</dt>
> +    <strong>If the target drive has a free partition with sufficient freespace, install will proceed without further partitioning intervention</strong>
> +        <dd> The drive corresponds to the drive on the chart (e.g /dev/sda) and the bar is divided</dd>

Ah, the hazards of blindly copying'n'pasting! There's a space in the original too, but I shall fix it :)

> +    <dt>Move the greyslider bar that separates the blue sections as appropriate</dt>
> +        <dd>The slider bar can be set as appropriate</dd>
> +    <dt>Click on the Install Now button</dt>
> +    <dt> A dialog will appear  asking if you want to write the changes to disk. Select Continue.</dt>

Same story

> +        <dd>The 'Where are you?' screen is displayed</dd>
> +  </ut:test>
> +
> +  <ut:test id="manual-partitions">
> +    <dt>Select Something Else</dt>
> +        <dd>A screen showing the current hard disks and partition layouts is displayed</dd>
> +    <dt>Select the drive you wish to partition and use the Add '+', Change 'Change...', and Delete '-' buttons to create your desired scheme</dt>
> +        <dd>The screen updates showing your desired partitions and mount points</dd>
> +    <dt>Once you have your required partitioning scheme laid out, click on the Install Now button</dt>
> +        <dd>The 'Where are you?' screen is displayed</dd>
> +  </ut:test>
> +
> +  <ut:test id="finish">
> +    <dt>If your system is connected to the network, note the preselected timezone correspond with your timezone and the city indicated in the text box </dt>
> +        <dd>The timezone and city displayed match your timezone and the main city from your area</dd>
> +    <dt>Select your timezone, and click on the continue button</dt>
> +        <dd>The 'Who are you?' screen appears</dd>
> +    <dt>Input your initial user details and password <em>admin can not be used - it is a dedicated Linux User</em></dt>
> +        <dd>Name, username and password are accepted. Automatic login option is shown</dd>
> +        <dd>Continue button becomes available</dd>
> +    <dt>Press continue</dt>
> +        <dd>The 'Welcome to FAMILY ' slide is displayed</dd>
> +        <dd>The slideshow is entirely in your language</dd> 
> +    <dt>Wait for the installer to finish</dt>
> +        <dd>An 'Installation Complete' dialog appears</dd>
> +    <dt>Click the Restart now button</dt>
> +        <dd>GUI is shut down, a prompt to remove media and press Enter appears</dd>
> +    <dt>Remove the disc and press enter</dt>
> +        <dd>The machine is rebooted</dd>
> +  </ut:test>
> +
> +  <ut:test id="reboot-ubuntu">
> +    <dt>Allow the machine to reboot</dt>
> +        <dd>The system boots properly and loads into FAMILY showing username selected</dd>
> +  </ut:test>
> +
> +  <ut:test id="reboot-other">
> +    <dt>Allow the machine to reboot, select the first option at the grub menu</dt>
> +        <dd>Your new installation boots</dd>
> +    <dt>Reboot machine, select the previous installed system</dt>
> +    <dd>Previously installed system boots and operates as expected</dd>
> +  </ut:test>
> +
> +  <ut:case id="1300_Install (entire disk)">
> +    <ut:include ref="start" />
> +    <ut:include ref="entire-disk" />
> +    <ut:include ref="finish" />
> +    <ut:include ref="reboot-ubuntu" />
> +  </ut:case>
> +
> +  <ut:case id="1301_Install (auto-resize)">
> +    <ut:include ref="start" />
> +    <ut:include ref="auto-resize" />
> +    <ut:include ref="finish" />
> +    <ut:include ref="reboot-other" />
> +  </ut:case>
> +
> +  <ut:case id="1302_Install (manual partitioning)">
> +    <ut:include ref="start" />
> +    <ut:include ref="manual-partitions" />
> +    <ut:include ref="finish" />
> +    <ut:include ref="reboot-ubuntu" />
> +  </ut:case>
> +</ut:configuration>
> diff --git a/definitions/non_english_installation.xml b/definitions/non_english_installation.xml
> new file mode 100644
> index 0000000..10bf164
> --- /dev/null
> +++ b/definitions/non_english_installation.xml
> @@ -0,0 +1,142 @@
> +<?xml version="1.0" encoding="utf-8" ?>
> +
> +<!-- See TEMPLATE.xml for an explanation of this file layout -->
> +
> +<ut:configuration xmlns:ut="urn:com:ubuntu:tests">
> +  <ut:template>
> +    <p>The goal of this test case is to check that localization support is
> +      functional during the installation, <ut:var name="preamble" /></p>
> +    <dl>
> +      <ut:tests />
> +    </dl>
> +    <p>If <strong>all</strong> actions produce the expected results listed,
> +      please <a href="results#add_result">submit</a> a 'passed' result.</p>
> +    <p>If <strong>any</strong> action fails, or produces an unexpected result,
> +      please <a href="results#add_result">submit</a> a 'failed' result and <a
> +      href="../../buginstructions">file a bug</a>. Please be sure to include
> +      the bug number when you <a href="results#add_result">submit</a> your
> +      result.</p>
> +  </ut:template>
> +
> +  <ut:test id="start">
> +    <dt>Boot up the image. When you see the aubergine screen with an icon at the bottom, press any key to get the menu</dt>
> +        <dd>Language list will appear</dd>
> +    <dt>Use arrow keys to select language and press Enter</dt>
> +        <dd>Language list will close.</dd>
> +        <dd>The installer is localized from this screen onwards</dd>
> +    <dt>Boot up the iso using a CD/DVD or USB Key to a Live Session</dt>

Good point!

> +        <dd>The system boots properly and loads the installer displaying Welcome dialog with language selection and 'Try FAMILY' and 'Install FAMILY' buttons</dd>
> +    <dt>Click on the Install FAMILY icon</dt>
> +        <dd>The 'Keyboard Layout' screen appears</dd>
> +        <dd>The proposed keyboard corresponds with your keyboard</dd>
> +    <dt>Select your keyboard layout and click on continue</dt>
> +        <dd>The 'Preparing to install FAMILY' screen is displayed</dd>
> +    <dt>On the screen Preparing to install FAMILY, note the availability of the following components</dt>
> +        <dd>Available options should represent the state of your system accurately</dd>
> +        <dd>
> +            <ul>
> +                <li>(If network is available) Download updates while installing FAMILY</li>
> +                <li>(If on a 'laptop') Is plugged to a power source</li>
> +                <li>Install third-party software ... option available</li>
> +            </ul>
> +        </dd>
> +    <dt>Click on the continue button</dt>
> +        <dd>The 'Installation type' screen is displayed</dd>
> +    <dt>Note the state of the 'Erase disk and install FAMILY' radio button</dt>
> +        <dd>The 'Erase disk and install FAMILY' radio button is selected</dd>
> +    <dt>Click on the continue button (if there is only one hard disk in the system, the button should read 'Install now')</dt>
> +        <dd>If there is only one hard disk, the installer skips to the "Where are you?' screen. Otherwise, the 'Installation type' screen is displayed</dd>
> +    <dt>If there is only one hard disk, skip two steps to selecting the timezone (On the 'Where are you?' screen...). Otherwise, on the 'Installation type' screen verify that the drive selected on the Select drive list corresponds to the drive on the chart (e.g /dev/sda)</dt>
> +        <dd>Selected drive is displayed on the chart</dd>
> +    <dt>Verify that the full drive space is allocated</dt>
> +        <dd>Full drive space is allocated for installation</dd>
> +    <dt>Click on Install Now button</dt>
> +        <dd>The 'Where are you?' screen is displayed</dd>
> +  </ut:test>
> +
> +  <ut:test id="auto-timezone">
> +    <dt>If your system is connected to the network, note the preselected timezone correspond with your timezone and the city indicated in the text box </dt>
> +        <dd>The timezone and city displayed match your timezone and a city from your area</dd>
> +  </ut:test>
> +
> +  <ut:test id="user-setup">
> +    <dt>Select your timezone, and click on the continue button</dt>
> +        <dd>The 'Who are you?' screen appears</dd>
> +    <dt>Input your initial user details and password (Note admin can not be used - it is a dedicated Linux User)</dt>
> +        <dd>Name, username and password are accepted. Additionally, the continue button is enabled</dd>
> +    <dt>Click on the continue button</dt>
> +        <dd>The 'Welcome to FAMILY ' slide is displayed</dd>
> +        <dd>The installer's slideshow slides are completely localized</dd>
> +  </ut:test>
> +
> +  <ut:test id="disconnect-net">
> +    <dt>When the installer is installing the language packs, disconnect the Internet</dt>
> +  </ut:test>
> +
> +  <ut:test id="locale-net">
> +    <dt>Verify that your system is localized</dt>
> +        <dd>For any language, the system has to be fully localized. Note: the translation coverage of some languages might not be complete</dd>
> +        <dd>The calendar shows the regional settings correctly</dd>
> +  </ut:test>
> +
> +  <ut:test id="locale-no-net">
> +    <dt>Verify that your system is localized</dt>
> +        <dd>If you aren't using Bengali (bn), German (de), English (en), Spanish (es), French(fr), Portuguese (pt) or Xhosa (xh) a pop up appears showing saying your language support is not complete</dd>
> +        <dd>For any language, the system has to be fully localized. Note: the translation coverage of some languages might not be complete</dd>
> +        <dd>If you are using one of the above languages the calendar shows the regional settings correctly</dd>
> +  </ut:test>
> +
> +  <ut:test id="finish">
> +    <dt>Wait for the installer to finish</dt>
> +        <dd>An 'Installation Complete' dialog appears</dd>
> +    <dt>Click the Restart now button</dt>
> +        <dd>GUI is shut down, a prompt to remove media and press Enter appears</dd>
> +    <dt>Remove the disc and press enter</dt>
> +        <dd>The machine has been rebooted</dd>
> +    <dt>Allow the machine to reboot</dt>
> +        <dd>The system boots properly and loads into FAMILY</dd>
> +  </ut:test>
> +
> +  <ut:case id="1311_Non-English Installation Full Network Support">
> +    <ut:define name="preamble">
> +      and that language packs are downloaded and installed correctly
> +      from the Internet.
> +    </ut:define>
> +
> +    <ut:include ref="start" />
> +    <ut:include ref="auto-timezone" />
> +    <ut:include ref="user-setup" />
> +    <ut:include ref="locale-net" />
> +    <ut:include ref="finish"/>
> +  </ut:case>
> +
> +  <ut:case id="1312_Non-English Installation No Network">
> +    <ut:define name="preamble">
> +      and that language packs are installed correctly for those languages
> +      in the ISO, and that an informational message is shown prompting
> +      users to connect to the Internet to fully install language support
> +      for those languages not included.
> +    </ut:define>
> +
> +    <ut:include ref="start" />
> +    <ut:include ref="user-setup" />
> +    <ut:include ref="locale-no-net" />
> +    <ut:include ref="finish"/>
> +  </ut:case>
> +
> +  <ut:case id="1313_Installation Broken Internet">
> +    <ut:define name="preamble">
> +      and that language packs are installed correctly for those languages
> +      in the ISO. During the lang-packs installation, Internet breaks, and the
> +      installer handles it gracefully. After the installation is complete and
> +      the new system rebooted an informational message is shown prompting users
> +      to connect to the Internet to fully install language support.
> +    </ut:define>
> +
> +    <ut:include ref="start" />
> +    <ut:include ref="disconnect-net" />
> +    <ut:include ref="user-setup" />
> +    <ut:include ref="locale-no-net" />
> +    <ut:include ref="finish"/>
> +  </ut:case>
> +</ut:configuration>
> diff --git a/tools/test_case_gen b/tools/test_case_gen
> index 4309c11..39ead82 100755
> --- a/tools/test_case_gen
> +++ b/tools/test_case_gen
> @@ -269,5 +345,341 @@ class TestConfiguration:
>              raise ValueError(f'<ut:define name={var_name!r}> not found')
>  
>  
> +def _test_main():
> +    import doctest
> +    os.environ.pop('TEST', None) # Don't run the test-suite recursively!
> +    failures, total = doctest.testmod()
> +    return bool(failures)
> +
> +# Some extra doctests to bump coverage
> +
> +__test__ = {
> +    'substitute-prior-append': """
> +    The positioning of the substitution placeholder shouldn't matter; it can
> +    be the first child, or a later child::
> +
> +        >>> from xml.etree import ElementTree as et
> +        >>> xml = et.fromstring('<p>This <em>is</em> a <color /> fruit</p>')
> +        >>> color = et.fromstring('<color>blue</color>')
> +        >>> print(et.tostring(substitute(xml, './color', color)))
> +        b'<p>This <em>is</em> a blue fruit</p>'
> +        >>> xml = et.fromstring('<p>This <em>was</em><color /> fruit</p>')
> +        >>> color = et.fromstring('<color> yellow</color>')

Unfortunately not. This test is specifically constructed to hit a couple of edge cases the substitute function has to deal with.

In the first case, the <em> element has a .tail containing the string " a " after which the <color/> substitution element appears. In the second, the <em> element has a .tail containing None because there's no content at all following it (and for some bizarre reason, the etree API uses None instead of a blank string for this). That's why the spacing is rather weird in this case, because we need to cover that particular branch in substitute(). However, the commentary above the test case doesn't make that clear -- I'll improve it.

> +        >>> print(et.tostring(substitute(xml, './color', color)))
> +        b'<p>This <em>was</em> yellow fruit</p>'
> +    """,
> +
> +    'substitute-empty-cases': """
> +    The substitution must succeed even if the text/tail properties of the
> +    parent/prior elements are :data:`None`::
> +
> +        >>> from xml.etree import ElementTree as et
> +        >>> xml = et.fromstring('<p><content />?</p>')
> +        >>> content = et.fromstring('<content></content>')
> +        >>> print(et.tostring(substitute(xml, './content', content)))
> +        b'<p>?</p>'
> +        >>> xml = et.fromstring('<p><content />?</p>')
> +        >>> content = et.fromstring('<content>foo bar baz<br /></content>')
> +        >>> print(et.tostring(substitute(xml, './content', content)))
> +        b'<p>foo bar baz<br />?</p>'
> +    """,
> +
> +    'config-bad-root': """
> +    The document passed to TestConfiguration must have <ut:configuration> as
> +    its root element::
> +
> +        >>> from xml.etree import ElementTree as et
> +        >>> doc = et.fromstring("<a />")
> +        >>> config = TestConfiguration(doc)
> +        Traceback (most recent call last):
> +          File "<stdin>", line 3, in <module>
> +            config = TestConfiguration(doc)
> +          File "./tools/test_case_gen", line 258, in __init__
> +            raise ValueError(
> +        ValueError: Expected to find <ut:configuration> as the root element
> +
> +    And must have <ut:template> under <ut:configuration>::
> +
> +        >>> doc = et.fromstring('''
> +        ... <ut:configuration xmlns:ut="urn:com:ubuntu:tests">
> +        ... <foo />
> +        ... </ut:configuration>
> +        ... ''')
> +        >>> config = TestConfiguration(doc)
> +        Traceback (most recent call last):
> +          File "<stdin>", line 3, in <module>
> +            config = TestConfiguration(doc)
> +          File "./tools/test_case_gen", line 262, in __init__
> +            raise ValueError(
> +        ValueError: Expected to find <ut:template> under the <ut:configuration> element
> +
> +    Which must have <ut:tests> somewhere (indirectly) underneath it::
> +
> +        >>> doc = et.fromstring('''
> +        ... <ut:configuration xmlns:ut="urn:com:ubuntu:tests">
> +        ... <ut:template>Some content, but no tests!</ut:template>
> +        ... </ut:configuration>
> +        ... ''')
> +        >>> config = TestConfiguration(doc)
> +        Traceback (most recent call last):
> +          File "<stdin>", line 3, in <module>
> +            config = TestConfiguration(doc)
> +          File "./tools/test_case_gen", line 266, in __init__
> +            raise ValueError(
> +        ValueError: <ut:template> must include <ut:tests> somewhere within it
> +
> +    There must also be <ut:test> elements::
> +
> +        >>> doc = et.fromstring('''
> +        ... <ut:configuration xmlns:ut="urn:com:ubuntu:tests">
> +        ... <ut:template><ut:tests /></ut:template>
> +        ... </ut:configuration>
> +        ... ''')
> +        >>> config = TestConfiguration(doc)
> +        Traceback (most recent call last):
> +          File "<stdin>", line 3, in <module>
> +            config = TestConfiguration(doc)
> +          File "./tools/test_case_gen", line 277, in __init__
> +            raise ValueError(
> +        ValueError: Expected to find at least one <ut:test> under the <ut:configuration> element
> +
> +    Which must have "id" attributes::
> +
> +        >>> doc = et.fromstring('''
> +        ... <ut:configuration xmlns:ut="urn:com:ubuntu:tests">
> +        ... <ut:template><ut:tests /></ut:template>
> +        ... <ut:test></ut:test>
> +        ... </ut:configuration>
> +        ... ''')
> +        >>> config = TestConfiguration(doc)
> +        Traceback (most recent call last):
> +          File "<stdin>", line 3, in <module>
> +            config = TestConfiguration(doc)
> +          File "./tools/test_case_gen", line 274, in __init__
> +            raise ValueError(
> +        ValueError: Missing "id" attribute in {urn:com:ubuntu:tests}test
> +
> +    Finally, there must also be <ut:case> elements::
> +
> +        >>> doc = et.fromstring('''
> +        ... <ut:configuration xmlns:ut="urn:com:ubuntu:tests">
> +        ... <ut:template><ut:tests /></ut:template>
> +        ... <ut:test id="foo"></ut:test>
> +        ... </ut:configuration>
> +        ... ''')
> +        >>> config = TestConfiguration(doc)
> +        Traceback (most recent call last):
> +          File "<stdin>", line 3, in <module>
> +            config = TestConfiguration(doc)
> +          File "./tools/test_case_gen", line 289, in __init__
> +            raise ValueError(
> +        ValueError: Expected to find at least one <ut:case> under the <ut:configuration> element
> +
> +    Which must also have "id" attributes::
> +
> +        >>> doc = et.fromstring('''
> +        ... <ut:configuration xmlns:ut="urn:com:ubuntu:tests">
> +        ... <ut:template><ut:tests /></ut:template>
> +        ... <ut:test id="foo"></ut:test>
> +        ... <ut:case></ut:case>
> +        ... </ut:configuration>
> +        ... ''')
> +        >>> config = TestConfiguration(doc)
> +        Traceback (most recent call last):
> +          File "<stdin>", line 3, in <module>
> +            config = TestConfiguration(doc)
> +          File "./tools/test_case_gen", line 286, in __init__
> +            raise ValueError(
> +        ValueError: Missing "id" attribute in <ut:case>
> +    """,
> +
> +    'config-bad-defines': """
> +    <ut:define> elements must all have a "name" attribute::
> +
> +        >>> doc = et.fromstring('''
> +        ... <ut:configuration xmlns:ut="urn:com:ubuntu:tests">
> +        ... <ut:template><ut:tests /></ut:template>
> +        ... <ut:test id="foo"></ut:test>
> +        ... <ut:case id="1_foo"></ut:case>
> +        ... <ut:define>Some content</ut:define>
> +        ... </ut:configuration>
> +        ... ''')
> +        >>> config = TestConfiguration(doc)
> +        Traceback (most recent call last):
> +          File "<stdin>", line 3, in <module>
> +            config = TestConfiguration(doc)
> +          File "./tools/test_case_gen", line 310, in __init__
> +            raise ValueError(
> +        ValueError: Missing "name" attribute in <ut:define>
> +    """,
> +
> +    'config-bad-include': """
> +    <ut:include> elements must all have a "ref" attribute::
> +
> +        >>> doc = et.fromstring('''
> +        ... <ut:configuration xmlns:ut="urn:com:ubuntu:tests">
> +        ... <ut:template><ut:tests /></ut:template>
> +        ... <ut:test id="foo"></ut:test>
> +        ... <ut:case id="1_foo"><ut:include /></ut:case>
> +        ... </ut:configuration>
> +        ... ''')
> +        >>> config = TestConfiguration(doc)
> +        >>> config['1_foo']
> +        Traceback (most recent call last):
> +          File "<stdin>", line 3, in <module>
> +            config = TestConfiguration(doc)
> +          File "./tools/test_case_gen", line 343, in __init__
> +            raise ValueError(
> +        ValueError: In <ut:case id='1_foo'>: Missing "ref" attribute in <ut:include>
> +
> +    And whatever <ut:test> is referenced must actually exist::
> +
> +        >>> doc = et.fromstring('''
> +        ... <ut:configuration xmlns:ut="urn:com:ubuntu:tests">
> +        ... <ut:template><ut:tests /></ut:template>
> +        ... <ut:test id="foo"></ut:test>
> +        ... <ut:case id="1_foo"><ut:include ref="bar" /></ut:case>
> +        ... </ut:configuration>
> +        ... ''')
> +        >>> config = TestConfiguration(doc)
> +        >>> config['1_foo']
> +        Traceback (most recent call last):
> +          File "<stdin>", line 3, in <module>
> +            config = TestConfiguration(doc)
> +          File "./tools/test_case_gen", line 347, in __init__
> +            raise ValueError(
> +        ValueError: In <ut:case id='1_foo'>: <ut:test id='bar'> not found
> +    """,
> +
> +    'config-bad-var': """
> +    <ut:var> elements must have a "name" attribute::
> +
> +        >>> doc = et.fromstring('''
> +        ... <ut:configuration xmlns:ut="urn:com:ubuntu:tests">
> +        ... <ut:template><ut:tests /></ut:template>
> +        ... <ut:test id="foo">
> +        ...   <dt><ut:var /></dt>
> +        ...   <dd></dd>
> +        ... </ut:test>
> +        ... <ut:case id="1_foo"><ut:include ref="foo" /></ut:case>
> +        ... </ut:configuration>
> +        ... ''')
> +        >>> config = TestConfiguration(doc)
> +        >>> config['1_foo']
> +        Traceback (most recent call last):
> +          File "<stdin>", line 3, in <module>
> +            config = TestConfiguration(doc)
> +          File "./tools/test_case_gen", line 360, in __init__
> +            raise ValueError(
> +        ValueError: In <ut:case id='1_foo'>: Missing "name" attribute in <ut:var>
> +
> +    And whatever <ut:var> is referenced must actually exist::
> +
> +        >>> doc = et.fromstring('''
> +        ... <ut:configuration xmlns:ut="urn:com:ubuntu:tests">
> +        ... <ut:template><ut:tests /></ut:template>
> +        ... <ut:test id="foo">
> +        ...   <dt><ut:var name="my-var" /></dt>
> +        ...   <dd></dd>
> +        ... </ut:test>
> +        ... <ut:case id="1_foo"><ut:include ref="foo" /></ut:case>
> +        ... </ut:configuration>
> +        ... ''')
> +        >>> config = TestConfiguration(doc)
> +        >>> config['1_foo']
> +        Traceback (most recent call last):
> +          File "<stdin>", line 3, in <module>
> +            config = TestConfiguration(doc)
> +          File "./tools/test_case_gen", line 364, in __init__
> +            raise ValueError(
> +        ValueError: In <ut:case id='1_foo'>: <ut:define name='my-var'> not found
> +    """,
> +
> +    'config-template-var': """
> +     Templates can contain <ut:var> elements just like <ut:test> can::
> +
> +        >>> doc = et.fromstring('''
> +        ... <ut:configuration xmlns:ut="urn:com:ubuntu:tests">
> +        ... <ut:template><ut:var name="foo" /><ut:tests /></ut:template>
> +        ... <ut:test id="foo"><dt /><dd /></ut:test>
> +        ... <ut:case id="1_foo">
> +        ...   <ut:define name="foo">FOO!</ut:define>
> +        ...   <ut:include ref="foo" />
> +        ... </ut:case>
> +        ... </ut:configuration>
> +        ... ''')
> +        >>> config = TestConfiguration(doc)
> +        >>> print(et.tostring(config['1_foo'], encoding='unicode'))
> +        <ns0:template xmlns:ns0="urn:com:ubuntu:tests">FOO!
> +          <dt /><dd />
> +        </ns0:template>
> +        <BLANKLINE>
> +    """,
> +
> +    'main --help': """
> +    Running the main function with --help results in help output::
> +
> +        >>> try:
> +        ...     main(['--help']) # doctest: +ELLIPSIS
> +        ... except SystemExit:
> +        ...     pass
> +        usage: test_case_gen [-h] [-o DIR] XML-FILE
> +        ...
> +    """,
> +
> +    'main works': """
> +    Running the main function with a valid configuration results in output
> +    to the specified directory::
> +
> +        >>> import io
> +        >>> import tempfile
> +        >>> from pathlib import Path
> +        >>> tmp = tempfile.TemporaryDirectory()
> +        >>> xml = io.open(Path(tmp.name) / 'config.xml', 'w')
> +        >>> xml.write('''
> +        ... <ut:configuration xmlns:ut="urn:com:ubuntu:tests">
> +        ...   <ut:template>
> +        ...     Before tests
> +        ...     <ut:tests />
> +        ...     After tests
> +        ...   </ut:template>
> +        ...   <ut:test id="button-test">
> +        ...     <dt>Press the big <ut:var name="color" /> button</dt>
> +        ...     <dd>Everything goes <ut:var name="result" /></dd>
> +        ...   </ut:test>
> +        ...   <ut:case id="1_dr_strangelove">
> +        ...     <ut:define name="color">red</ut:define>
> +        ...     <ut:define name="result">boom</ut:define>
> +        ...     <ut:include ref="button-test" />
> +        ...   </ut:case>
> +        ... </ut:configuration>
> +        ... ''')
> +        483
> +        >>> config_file = xml.name
> +        >>> xml.close()
> +        >>> main(['-o', tmp.name, config_file])
> +        >>> output = Path(tmp.name) / '1_dr_strangelove'
> +        >>> output.exists()
> +        True
> +        >>> print(output.read_text()) # doctest: +ELLIPSIS
> +        <!-- Please do not edit this file directly; it was generated with the
> +             tools/test_case_gen script using the following configuration as input:
> +             .../config.xml
> +        -->
> +        <BLANKLINE>
> +            Before tests
> +        <BLANKLINE>
> +        <BLANKLINE>
> +            <dt>Press the big red button</dt>
> +            <dd>Everything goes boom</dd>
> +        <BLANKLINE>
> +        <BLANKLINE>
> +            After tests
> +        <BLANKLINE>
> +        >>> tmp.cleanup()
> +    """,
> +}
> +
> +
>  if __name__ == '__main__':
> -    main()
> +    sys.exit(main())


-- 
https://code.launchpad.net/~waveform/ubuntu-manual-tests/+git/ubuntu-manual-tests/+merge/410534
Your team Ubuntu Testcase Admins is requested to review the proposed merge of ~waveform/ubuntu-manual-tests:doctest into ubuntu-manual-tests:master.



References