Git Product home page Git Product logo

hitchdev / hitchstory Goto Github PK

View Code? Open in Web Editor NEW
84.0 5.0 3.0 2.62 MB

Type-safe YAML integration tests. Tests that write your docs. Tests that rewrite themselves.

Home Page: https://hitchdev.com/hitchstory

License: Other

Python 93.62% Jinja 3.59% Shell 2.78%
bdd bdd-framework testing-framework testing tests specification yaml strongly-typed bdd-style-testing-framework bdd-tests behavior-driven-development bdd-specs documentation-tool pytest pytest-bdd pytest-plugin integration-testing test-automation

hitchstory's Issues

`hk regression` and `hk bdd dirty` fail on Arch Linux

I have installed hitchkey with pip install -U hitchkey directly before trying to run tests and I am trying both commands on the current strictyaml master.

❯ pip show hitchkey       
Name: hitchkey
Version: 0.6.1
Summary: HitchKey bootstrapper - set up a development environment.
Home-page: https://hitchtest.readthedocs.org/
Author: Colm O'Connor
Author-email: [email protected]
License: AGPL
Location: /home/daniel/.local/lib/python3.9/site-packages
Requires: 
Required-by: 
❯ hk regression
CommandError

Can't create CommandPath object: /home/daniel/.hitch/0phcf6/py3.7.0/bin does not exist.
RUNNING A YAMLError will be raised if there are syntactic problems, violations of your schema or use of disallowed YAML features/For example, a schema violation in /home/daniel/projects/strictyaml/hitch/story/quickstart.story ... Downloading Python-2.7.14.tar.xz...
-> https://www.python.org/ftp/python/2.7.14/Python-2.7.14.tar.xz
Installing Python-2.7.14...

BUILD FAILED (Arch rolling using python-build 20180424)

Inspect or clean up the working tree at /tmp/python-build.20210814125339.59626
Results logged to /tmp/python-build.20210814125339.59626.log

Last 10 log lines:
/usr/bin/ld: libpython2.7.a(posixmodule.o): in function `posix_tempnam':
/tmp/python-build.20210814125339.59626/Python-2.7.14/./Modules/posixmodule.c:7589: warning: the use of `tempnam' is dangerous, better use `mkstemp'
./python -E -S -m sysconfig --generate-posix-vars ;\
if test $? -ne 0 ; then \
	echo "generate-posix-vars failed" ; \
	rm -f ./pybuilddir.txt ; \
	exit 1 ; \
fi
generate-posix-vars failed
make: *** [Makefile:514: pybuilddir.txt] Error 1
FAILED in 27.5 seconds.



[1]: function 'set_up'
  /home/daniel/projects/strictyaml/hitch/engine.py

    
        70 :             ).with_python_version(self.given["python version"])\
        71 :              .with_packages({"ruamel.yaml": self.given["ruamel version"]})
    --> 72 :             self.pylibrary.ensure_built()
        73 :             self.python = self.pylibrary.bin.python
    
    

[2]: function 'ensure_built'
  /home/daniel/.hitch/0phcf6/hvenv/lib/python3.9/site-packages/hitchbuild/build.py

    
        249 :     def ensure_built(self):
        250 :         with BuildContextManager(self):
    --> 251 :             self.build()
        252 : 
    
    

[3]: function 'build'
  /home/daniel/.hitch/0phcf6/hvenv/lib/python3.9/site-packages/hitchpylibrarytoolkit/build.py

    
        56 :     def build(self):
        57 :         pipinstalle = self.virtualenv.incomplete()
    --> 58 :         self.virtualenv.ensure_built()
        59 :         if pipinstalle:
    
    

[4]: function 'ensure_built'
  /home/daniel/.hitch/0phcf6/hvenv/lib/python3.9/site-packages/hitchbuild/build.py

    
        249 :     def ensure_built(self):
        250 :         with BuildContextManager(self):
    --> 251 :             self.build()
        252 : 
    
    

[5]: function 'build'
  /home/daniel/.hitch/0phcf6/hvenv/lib/python3.9/site-packages/hitchbuildpy/virtualenv.py

    
        39 :             self.build_path.rmtree(ignore_errors=True)
        40 :             self.build_path.mkdir()
    --> 41 :             self.base_python.build.ensure_built()
        42 :             self.base_python.build.bin.virtualenv(self.build_path).run()
    
    

[6]: function 'ensure_built'
  /home/daniel/.hitch/0phcf6/hvenv/lib/python3.9/site-packages/hitchbuild/build.py

    
        249 :     def ensure_built(self):
        250 :         with BuildContextManager(self):
    --> 251 :             self.build()
        252 : 
    
    

[7]: function 'build'
  /home/daniel/.hitch/0phcf6/hvenv/lib/python3.9/site-packages/hitchbuildpy/pyenv.py

    
        22 :             self.build_path.mkdir()
        23 : 
    --> 24 :             Command(
        25 :                 Path(__file__).dirname().abspath().joinpath("bin", "python-build")
    
    

[8]: function 'run'
  /home/daniel/.hitch/0phcf6/hvenv/lib/python3.9/site-packages/commandlib/command.py

    
        234 : 
        235 :         if returncode != 0 and not self._ignore_errors:
    --> 236 :             raise CommandError('"{0}" failed (err code {1})'.format(
        237 :                 self.__repr__(),
    
    

commandlib.exceptions.CommandError
  commandlib exception.
"/home/daniel/.hitch/0phcf6/hvenv/lib/python3.9/site-packages/hitchbuildpy/bin/python-build 2.7.14 /home/daniel/.hitch/share/python2.7.14" failed (err code 1)
RUNNING A YAMLError will be raised if there are syntactic problems, violations of your schema or use of disallowed YAML features/For example, a schema violation in /home/daniel/projects/strictyaml/hitch/story/quickstart.story ... Downloading Python-2.7.14.tar.xz...
-> https://www.python.org/ftp/python/2.7.14/Python-2.7.14.tar.xz
Installing Python-2.7.14...

BUILD FAILED (Arch rolling using python-build 20180424)

Inspect or clean up the working tree at /tmp/python-build.20210814125407.66268
Results logged to /tmp/python-build.20210814125407.66268.log

Last 10 log lines:
/usr/bin/ld: libpython2.7.a(posixmodule.o): in function `posix_tempnam':
/tmp/python-build.20210814125407.66268/Python-2.7.14/./Modules/posixmodule.c:7589: warning: the use of `tempnam' is dangerous, better use `mkstemp'
./python -E -S -m sysconfig --generate-posix-vars ;\
if test $? -ne 0 ; then \
	echo "generate-posix-vars failed" ; \
	rm -f ./pybuilddir.txt ; \
	exit 1 ; \
fi
generate-posix-vars failed
make: *** [Makefile:514: pybuilddir.txt] Error 1
FAILED in 27.6 seconds.



[1]: function 'set_up'
  /home/daniel/projects/strictyaml/hitch/engine.py

    
        70 :             ).with_python_version(self.given["python version"])\
        71 :              .with_packages({"ruamel.yaml": self.given["ruamel version"]})
    --> 72 :             self.pylibrary.ensure_built()
        73 :             self.python = self.pylibrary.bin.python
    
    

[2]: function 'ensure_built'
  /home/daniel/.hitch/0phcf6/hvenv/lib/python3.9/site-packages/hitchbuild/build.py

    
        249 :     def ensure_built(self):
        250 :         with BuildContextManager(self):
    --> 251 :             self.build()
        252 : 
    
    

[3]: function 'build'
  /home/daniel/.hitch/0phcf6/hvenv/lib/python3.9/site-packages/hitchpylibrarytoolkit/build.py

    
        56 :     def build(self):
        57 :         pipinstalle = self.virtualenv.incomplete()
    --> 58 :         self.virtualenv.ensure_built()
        59 :         if pipinstalle:
    
    

[4]: function 'ensure_built'
  /home/daniel/.hitch/0phcf6/hvenv/lib/python3.9/site-packages/hitchbuild/build.py

    
        249 :     def ensure_built(self):
        250 :         with BuildContextManager(self):
    --> 251 :             self.build()
        252 : 
    
    

[5]: function 'build'
  /home/daniel/.hitch/0phcf6/hvenv/lib/python3.9/site-packages/hitchbuildpy/virtualenv.py

    
        39 :             self.build_path.rmtree(ignore_errors=True)
        40 :             self.build_path.mkdir()
    --> 41 :             self.base_python.build.ensure_built()
        42 :             self.base_python.build.bin.virtualenv(self.build_path).run()
    
    

[6]: function 'ensure_built'
  /home/daniel/.hitch/0phcf6/hvenv/lib/python3.9/site-packages/hitchbuild/build.py

    
        249 :     def ensure_built(self):
        250 :         with BuildContextManager(self):
    --> 251 :             self.build()
        252 : 
    
    

[7]: function 'build'
  /home/daniel/.hitch/0phcf6/hvenv/lib/python3.9/site-packages/hitchbuildpy/pyenv.py

    
        22 :             self.build_path.mkdir()
        23 : 
    --> 24 :             Command(
        25 :                 Path(__file__).dirname().abspath().joinpath("bin", "python-build")
    
    

[8]: function 'run'
  /home/daniel/.hitch/0phcf6/hvenv/lib/python3.9/site-packages/commandlib/command.py

    
        234 : 
        235 :         if returncode != 0 and not self._ignore_errors:
    --> 236 :             raise CommandError('"{0}" failed (err code {1})'.format(
        237 :                 self.__repr__(),
    
    

commandlib.exceptions.CommandError
  commandlib exception.
"/home/daniel/.hitch/0phcf6/hvenv/lib/python3.9/site-packages/hitchbuildpy/bin/python-build 2.7.14 /home/daniel/.hitch/share/python2.7.14" failed (err code 1)

❯ hk bdd dirty
RUNNING Dirty load/Flow style mapping in /home/daniel/projects/strictyaml/hitch/story/dirty-load.story ... Downloading Python-3.7.0.tar.xz...
-> https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
Installing Python-3.7.0...
Installed Python-3.7.0 to /home/daniel/.hitch/share/python3.7.0

FAILED in 108.9 seconds.



[1]: function 'set_up'
  /home/daniel/projects/strictyaml/hitch/engine.py

    
        70 :             ).with_python_version(self.given["python version"])\
        71 :              .with_packages({"ruamel.yaml": self.given["ruamel version"]})
    --> 72 :             self.pylibrary.ensure_built()
        73 :             self.python = self.pylibrary.bin.python
    
    

[2]: function 'ensure_built'
  /home/daniel/.hitch/0phcf6/hvenv/lib/python3.9/site-packages/hitchbuild/build.py

    
        249 :     def ensure_built(self):
        250 :         with BuildContextManager(self):
    --> 251 :             self.build()
        252 : 
    
    

[3]: function 'build'
  /home/daniel/.hitch/0phcf6/hvenv/lib/python3.9/site-packages/hitchpylibrarytoolkit/build.py

    
        56 :     def build(self):
        57 :         pipinstalle = self.virtualenv.incomplete()
    --> 58 :         self.virtualenv.ensure_built()
        59 :         if pipinstalle:
    
    

[4]: function 'ensure_built'
  /home/daniel/.hitch/0phcf6/hvenv/lib/python3.9/site-packages/hitchbuild/build.py

    
        249 :     def ensure_built(self):
        250 :         with BuildContextManager(self):
    --> 251 :             self.build()
        252 : 
    
    

[5]: function 'build'
  /home/daniel/.hitch/0phcf6/hvenv/lib/python3.9/site-packages/hitchbuildpy/virtualenv.py

    
        39 :             self.build_path.rmtree(ignore_errors=True)
        40 :             self.build_path.mkdir()
    --> 41 :             self.base_python.build.ensure_built()
        42 :             self.base_python.build.bin.virtualenv(self.build_path).run()
    
    

[6]: function 'ensure_built'
  /home/daniel/.hitch/0phcf6/hvenv/lib/python3.9/site-packages/hitchbuild/build.py

    
        249 :     def ensure_built(self):
        250 :         with BuildContextManager(self):
    --> 251 :             self.build()
        252 : 
    
    

[7]: function 'build'
  /home/daniel/.hitch/0phcf6/hvenv/lib/python3.9/site-packages/hitchbuildpy/pyenv.py

    
        30 :                 self.bin.easy_install("--upgrade", "pip").run()
        31 :             else:
    --> 32 :                 self.bin.pip("install", "pip", "--upgrade").run()
        33 :             self.bin.pip("install", "virtualenv", "--upgrade")\
    
    

[8]: function 'run'
  /home/daniel/.hitch/0phcf6/hvenv/lib/python3.9/site-packages/commandlib/command.py

    
        234 : 
        235 :         if returncode != 0 and not self._ignore_errors:
    --> 236 :             raise CommandError('"{0}" failed (err code {1})'.format(
        237 :                 self.__repr__(),
    
    

commandlib.exceptions.CommandError
  commandlib exception.
"/home/daniel/.hitch/share/python3.7.0/bin/pip install pip --upgrade" failed (err code -11)

It looks like it is trying to install a specific python version and is failing... Is there a way to tell it to use the system python version?

Contributing Guide

Hi @crdoconnor

I'm thinking of using hitchstory for another project (remember we met at Babylon).

I was going to run through the tests and check everything was working with Python 3.9 (maybe 3.10). What's the best way for me to get setup for contributing? Happy to write this up in a contributing guide.

Cheers!

Accessing Pytest fixtures from Engine

I'm testing some Django code, and I'd like to use the Django test client. This is available in Pytest via pytest-django providing a client fixture.

It's meant to be used like this:

def test_with_client(client):
    response = client.get('/')
    assert response.content == 'Foobar'

I think the most natural way to adapt this to the Hitchstory approach is to add the decorator to my test_foo Pytest function:

def test_foobar(client):
    hs.named("Something with a client").play()

but it's not obvious there's a clean way to pass the client object through so that the engine can get at it. I think the client is recreated with each test (it potentially holds state) so we don't want to create the client once and include it when instantiating the engine.

Getting FileNotFound errors when running example tests

Hi,
I've recently discovered hitchstory and been trying to get the rewrite test_correct_my_spelling example working.
The issue I'm currently seeing is that when running $ STORYMODE=rewrite ./run.sh pytest -k test_correct_my_spelling I'm getting the error No such file or directory: '/src/tests/docstory.yml.

I'm wondering if this is to do with the recent directory changes?

It appears a lot of the links on that example page are also broken as a result of the directoy changes.

Or is there something I'm doing wrong?

Thanks

untrue statement on https://hitchdev.com/strictyaml/why/implicit-typing-removed/

Hi there hitchdev!

I found no better place to send in the following pedantry, so here it goes:

As of today (2023-02-25), the webpage https://hitchdev.com/strictyaml/why/implicit-typing-removed/ demonstrates the "The Norway Problem", where the YAML specification directs the parsing of values (without surrounding quotes) like GB, IE, FR, and DE into strings, but to the surprise of many users mandates parsing the value (again without surrounding quotes) NO, the two letter code for Norway, as boolean false.
Further down, also the following statement is made:

The most tragic aspect of this bug, however, is that it is intended behavior according to the YAML 1.2 specification.

Where the last part of the sentence is a hyperlink to https://yaml.org/spec/1.2.2/

However,

  1. for the 1.2.2 specification, i could not find the paragraph where the string "NO" is a valid format of the boolean true.

  2. The 1.2.2 changelog of the specification (link here: https://yaml.org/spec/1.2.2/ext/changes/ ) explicitely lists the change, that starting with the revision 1.2.0 (2009-07-21):

    Only true and false strings are parsed as booleans (including True and TRUE); y, yes, on, and their negative counterparts are parsed as strings.

Notwithstanding all the other aspects of YAML that justify StrictYaml to refuse to parse certain features of YAML, this particular statement on the homepage, that NO (without quotes) shall be parsed into a boolean false when pedanticly following the 1.2.2 revision of the YAML-Spec is not true.

I would suggest that

  • The last part of the above quoted sentence on the homepage is changed to "YAML 1.1 specification";
  • the hyperlink points to the YAML 1.1.0 revision;
  • a note is added to the sentence that this particular problem is not present in the YAML 1.2 specification any longer [*].

best regards,

Max

[*] which means that some valid yaml documents are parsed differently with a yaml-1.1 parser and a yaml-1.2 parser, and this demonstrates another aspect of the YAML spec to be on the lookout for.

the wiki link code to code

I think the wiki link should take me to the wiki, or wiki should be disabled so it doesn't show in the tab list for the project.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.