Replies: 2 comments 1 reply
-
Hi, I think it's fine to add a datetime value Generators module on our end, and stop relying on faker for this purpose. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thank you for your prompt response. I understand that opting to discontinue reliance on Faker for datetime value generation is a valid option. Thanks again for your time and consideration. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I am grateful for Polyfactory, which has significantly simplified my testing process. I often use a plugin called Syrupy for my tests, which takes snapshots and checks for differences from previous results.
During testing, I noticed that even with a fixed random_seed, the datetime type values were different. I am curious if this is the expected behavior and would appreciate it if we could align our understanding on this.
Below is my testing program:
Excerpt from the test error:
The cause of the changing test results is that the function used to generate the datetime type values is Faker's date_time_between. As discussed in Faker's Issue, this is understood to be intentional, as the difference from the current time (time_delta) is fixed. Here is the relevant link: joke2k/faker#1791.
However, whether it is desirable for the value to change each time with a fixed random_seed for datetime in Polyfactory is a separate issue that I'd like to discuss.
There are two methods to standardize the test with the current implementation. One is to fix the current time by adding the freezegun module, and the other is to override the value generation process with get_provider_map.
Method using the freezegun module:
Overriding the value generation process with get_provider_map:
I look forward to your feedback.
Beta Was this translation helpful? Give feedback.
All reactions