Comments (5)
I'm guessing this is because it's an integer and user_id is being implicitly converted to an int at some point.
Because it might be desirable to actually have the distinction between an integer and a string being returned I'm not sure what the best thing to do is to fix this - it should at least print something more useful like
Value mismatch: '159295' (type: int) vs '159295' (type: str)
from tavern.
@michaelboulton This has been released right?
from tavern.
Currently, values from variables can only be passed by using string formatting (user_id: "{user_id}"
). This loses any information about the original data type.
We should come up with another way of passing variables as they are. This might also be useful for passing whole json-blocks as data. String-formatting should stay as it has its own use case (e.g. Authorization
header formatting).
Maybe a special token might be appropriate here. I am not sure which tokens are reserved in the yaml spec, so the symbol might need to be changed.
user_id: $user_id
from tavern.
This can be done using the yaml 'tags' (specs here http://www.yaml.org/spec/1.2/spec.html#id2803311) - for example:
request:
json:
user_id: !!int "{user_id_as_int:d}"
and custom tags can also be added (this is used for !include
and !uuid
).
It should be possible to make this 'pluggable' in future because it is just registering a function (eg
Lines 29 to 30 in 3f395e0
from tavern.
Using the default yaml tags does not work, unfortunately, because they are constructed before any string formatting is done.
I propose a solution involving an intermediate token which gets converted after string formatting is done. See #50 for my approach.
from tavern.
Related Issues (20)
- question about nullable fields. HOT 1
- __main__.py: error: unrecognized arguments: --tavern-merge-ext-function-values HOT 3
- How feasible would be write a plugin to transform a shared stage into a session-scoped fixture? HOT 1
- Tavern Marks Broken with Pytest 7.3.0 HOT 5
- Question about external function kwargs in requests HOT 1
- verify_response_with not working on mqtt_response HOT 2
- 2FA Log In HOT 2
- Try to use the external function in the URL HOT 1
- Variable in skip when on test HOT 2
- Curly braces in JSON values of criteria causes error when test fails HOT 1
- "finally" block errors with BadSchemaError HOT 1
- How to measure coverage for tavern tests? HOT 1
- Parametrize for request parameters (path, query) HOT 1
- Support for YAML Indexing and Advanced Assertions HOT 1
- DeprecationWarning with jsonschema > 4 HOT 1
- INQUIRY: upload multipart form file using external functions HOT 1
- 3.0 Release HOT 1
- gRPC multi stage test HOT 3
- Enhance finally block to support referenced stages HOT 1
- BadSchemaError trying to use redirect_query_params key in response HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tavern.