Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

human_to_bytes: Unit tests for isbits arg of human_to_bytes function, adding explanation of isbits to the docstring #58623

Open
wants to merge 16 commits into
base: devel
from

Conversation

Projects
None yet
5 participants
@Andersson007
Copy link
Contributor

commented Jul 2, 2019

Co-authored-by: Sviatoslav Sydorenko webknjaz@redhat.com

SUMMARY
  1. Unit tests for isbits arg of human_to_bytes function from lib/ansible/module_utils/common/text/formatters.py

  2. Add explanation about isbits to formatters.py and note to validation.py to clarify how the function works.

ISSUE TYPE
  • Bugfix Pull Request

@Andersson007 Andersson007 force-pushed the Andersson007:human_to_bytes_isbits branch from 5c4f120 to 3c12fea Jul 2, 2019

@Andersson007

This comment has been minimized.

Copy link
Contributor Author

commented Jul 2, 2019

@samdoran , hey, as I promised yesterday there are tests for isbits. This PR also contains explanation about how the function handles isbits value.
Regarding my research, we might decide it needs refactoring or not.

@ansibot ansibot added needs_revision and removed core_review labels Jul 2, 2019

@samdoran samdoran self-assigned this Jul 2, 2019

@bcoca bcoca removed the needs_triage label Jul 2, 2019

@bcoca bcoca requested a review from samdoran Jul 2, 2019

@ansibot ansibot added core_review and removed needs_revision labels Jul 2, 2019

@samdoran samdoran changed the title human_to_bytest: Unit tests for isbits arg of human_to_bytes function, adding explanation of isbits to the docstring human_to_bytes: Unit tests for isbits arg of human_to_bytes function, adding explanation of isbits to the docstring Jul 2, 2019

@ansibot ansibot added needs_revision and removed core_review labels Jul 3, 2019

@Andersson007

This comment has been minimized.

Copy link
Contributor Author

commented Jul 3, 2019

There are unrelated problems with azure tests that looks like because of #58576, so

ready_for_review

Andersson007 and others added some commits Jul 5, 2019

human_to_bytest: add unit tests for isbits - fix typo
Co-Authored-By: Sviatoslav Sydorenko <wk.cvs.github@sydorenko.org.ua>
@ansibot

This comment was marked as resolved.

Copy link
Contributor

commented Jul 5, 2019

The test ansible-test sanity --test pylint [explain] failed with 6 errors:

lib/ansible/module_utils/basic.py:89:0: syntax-error Cannot import 'ansible.module_utils.common.text.formatters' due to syntax error 'unindent does not match any outer indentation level (&lt;unknown&gt;, line 57)'
lib/ansible/module_utils/common/text/formatters.py:57:0: syntax-error unindent does not match any outer indentation level (&lt;unknown&gt;, line 57)
lib/ansible/module_utils/common/validation.py:15:0: syntax-error Cannot import 'ansible.module_utils.common.text.formatters' due to syntax error 'unindent does not match any outer indentation level (&lt;unknown&gt;, line 57)'
lib/ansible/module_utils/facts/hardware/linux.py:33:0: syntax-error Cannot import 'ansible.module_utils.common.text.formatters' due to syntax error 'unindent does not match any outer indentation level (&lt;unknown&gt;, line 57)'
lib/ansible/module_utils/facts/hardware/sunos.py:24:0: syntax-error Cannot import 'ansible.module_utils.common.text.formatters' due to syntax error 'unindent does not match any outer indentation level (&lt;unknown&gt;, line 57)'
test/units/module_utils/common/text/formatters/test_human_to_bytes.py:10:0: syntax-error Cannot import 'ansible.module_utils.common.text.formatters' due to syntax error 'unindent does not match any outer indentation level (&lt;unknown&gt;, line 57)'

The test ansible-test sanity --test pylint [explain] failed with 2 errors:

lib/ansible/modules/cloud/docker/docker_container.py:948:0: syntax-error Cannot import 'ansible.module_utils.common.text.formatters' due to syntax error 'unindent does not match any outer indentation level (&lt;unknown&gt;, line 57)'
lib/ansible/modules/cloud/vmware/vmware_host_facts.py:150:0: syntax-error Cannot import 'ansible.module_utils.common.text.formatters' due to syntax error 'unindent does not match any outer indentation level (&lt;unknown&gt;, line 57)'

The test ansible-test sanity --test ansible-doc --python 2.6 [explain] failed with the error:

Command "ansible-doc -t become doas dzdo enable ksu machinectl pbrun pfexec pmrun runas sesu su sudo" returned exit status 250.
>>> Standard Error
ERROR! Unexpected Exception, this is probably a bug: unindent does not match any outer indentation level (formatters.py, line 57)

The test ansible-test sanity --test ansible-doc --python 2.7 [explain] failed with the error:

Command "ansible-doc -t become doas dzdo enable ksu machinectl pbrun pfexec pmrun runas sesu su sudo" returned exit status 250.
>>> Standard Error
ERROR! Unexpected Exception, this is probably a bug: unindent does not match any outer indentation level (formatters.py, line 57)

The test ansible-test sanity --test ansible-doc --python 3.5 [explain] failed with the error:

Command "ansible-doc -t become doas dzdo enable ksu machinectl pbrun pfexec pmrun runas sesu su sudo" returned exit status 250.
>>> Standard Error
ERROR! Unexpected Exception, this is probably a bug: unindent does not match any outer indentation level (formatters.py, line 57)

The test ansible-test sanity --test ansible-doc --python 3.6 [explain] failed with the error:

Command "ansible-doc -t become doas dzdo enable ksu machinectl pbrun pfexec pmrun runas sesu su sudo" returned exit status 250.
>>> Standard Error
ERROR! Unexpected Exception, this is probably a bug: unindent does not match any outer indentation level (formatters.py, line 57)

The test ansible-test sanity --test ansible-doc --python 3.7 [explain] failed with the error:

Command "ansible-doc -t become doas dzdo enable ksu machinectl pbrun pfexec pmrun runas sesu su sudo" returned exit status 250.
>>> Standard Error
ERROR! Unexpected Exception, this is probably a bug: unindent does not match any outer indentation level (formatters.py, line 57)

The test ansible-test sanity --test ansible-doc --python 3.8 [explain] failed with the error:

Command "ansible-doc -t become doas dzdo enable ksu machinectl pbrun pfexec pmrun runas sesu su sudo" returned exit status 250.
>>> Standard Error
ERROR! Unexpected Exception, this is probably a bug: unindent does not match any outer indentation level (formatters.py, line 57)

The test ansible-test sanity --test docs-build [explain] failed with the error:

Command "/usr/bin/python3.6 test/sanity/code-smell/docs-build.py" returned exit status 1.
>>> Standard Error
Command 'make singlehtmldocs' failed with status code: 2
--> Standard Output
PYTHONPATH=../../lib ../bin/dump_config.py --template-file=../templates/config.rst.j2 --output-dir=rst/reference_appendices/ -d ../../lib/ansible/config/base.yml
mkdir -p rst/cli
PYTHONPATH=../../lib ../bin/generate_man.py --template-file=../templates/cli_rst.j2 --output-dir=rst/cli/ --output-format rst ../../lib/ansible/cli/*.py
Makefile:83: recipe for target 'cli' failed
--> Standard Error
Traceback (most recent call last):
  File "../bin/generate_man.py", line 253, in <module>
    allvars[cli_name] = opts_docs(cli_class_name, cli_name)
  File "../bin/generate_man.py", line 118, in opts_docs
    fromlist=[cli_class_name]), cli_class_name)
  File "/root/ansible/lib/ansible/cli/__init__.py", line 25, in <module>
    from ansible.parsing.dataloader import DataLoader
  File "/root/ansible/lib/ansible/parsing/dataloader.py", line 17, in <module>
    from ansible.module_utils.basic import is_executable
  File "/root/ansible/lib/ansible/module_utils/basic.py", line 89, in <module>
    from ansible.module_utils.common.text.formatters import (
  File "/root/ansible/lib/ansible/module_utils/common/text/formatters.py", line 57
    m = re.search(r'^\s*(\d*\.?\d*)\s*([A-Za-z]+)?', str(number), flags=re.IGNORECASE)
                                                                                     ^
IndentationError: unindent does not match any outer indentation level
make: *** [cli] Error 1

The test ansible-test sanity --test compile --python 2.6 [explain] failed with 1 error:

lib/ansible/module_utils/common/text/formatters.py:57:87: SyntaxError: m = re.search(r'^\s*(\d*\.?\d*)\s*([A-Za-z]+)?', str(number), flags=re.IGNORECASE)

The test ansible-test sanity --test compile --python 2.7 [explain] failed with 1 error:

lib/ansible/module_utils/common/text/formatters.py:57:87: SyntaxError: m = re.search(r'^\s*(\d*\.?\d*)\s*([A-Za-z]+)?', str(number), flags=re.IGNORECASE)

The test ansible-test sanity --test compile --python 3.5 [explain] failed with 1 error:

lib/ansible/module_utils/common/text/formatters.py:57:87: SyntaxError: m = re.search(r'^\s*(\d*\.?\d*)\s*([A-Za-z]+)?', str(number), flags=re.IGNORECASE)

The test ansible-test sanity --test compile --python 3.6 [explain] failed with 1 error:

lib/ansible/module_utils/common/text/formatters.py:57:87: SyntaxError: m = re.search(r'^\s*(\d*\.?\d*)\s*([A-Za-z]+)?', str(number), flags=re.IGNORECASE)

The test ansible-test sanity --test compile --python 3.7 [explain] failed with 1 error:

lib/ansible/module_utils/common/text/formatters.py:57:87: SyntaxError: m = re.search(r'^\s*(\d*\.?\d*)\s*([A-Za-z]+)?', str(number), flags=re.IGNORECASE)

The test ansible-test sanity --test compile --python 3.8 [explain] failed with 1 error:

lib/ansible/module_utils/common/text/formatters.py:57:87: SyntaxError: m = re.search(r'^\s*(\d*\.?\d*)\s*([A-Za-z]+)?', str(number), flags=re.IGNORECASE)

click here for bot help

@ansibot ansibot added needs_revision and removed core_review labels Jul 5, 2019

@Andersson007

This comment has been minimized.

Copy link
Contributor Author

commented Jul 5, 2019

ready_for_review

@ansibot ansibot added core_review and removed needs_revision labels Jul 5, 2019

@webknjaz
Copy link
Member

left a comment

:shipit:

@webknjaz

This comment has been minimized.

Copy link
Member

commented Jul 5, 2019

Let's wait for @samdoran to approve too.

Update test/units/module_utils/common/text/formatters/test_human_to_b…
…ytes.py

Co-Authored-By: Sviatoslav Sydorenko <wk.cvs.github@sydorenko.org.ua>
@Andersson007

This comment has been minimized.

Copy link
Contributor Author

commented Jul 5, 2019

@webknjaz thank you for reviewing and approving , the best experience (as always)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.