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

Issues with unit tests #696

Open
DustanBower opened this issue Jul 30, 2024 · 1 comment
Open

Issues with unit tests #696

DustanBower opened this issue Jul 30, 2024 · 1 comment

Comments

@DustanBower
Copy link

Not sure if this is a bug report, feature request, or request for documentation, but I'm having issues with unit tests and ursina.

I'd like to write some tests to test my physics code for a 2d game I'm working on. My current iteration process makes it easy to introduce physics bugs that I don't notice right away, and I'd like to have tests to ensure later changes don't break things.

I'm using pytest, and I'm completely stumped on getting tests to work. I don't have any errors. My current attempt just tries to load and run the game without even testing anything. I have a main() function which just does my game setup and runs app.run(). I call main() in the test. The game appears, but doesn't do anything and doesn't respond to input. The update() function doesn't appear to be called unless I manually call it. I'm importing everything from ursina (from ursina import *) as the documentation recommends.

Initially I thought it might be a namespace issue of some kind, but I'm doing the same imports in my actual game as I am in my tests. I don't see any unit tests examples in the code or documentation that I could use as guidelines either.

@DustanBower
Copy link
Author

The issue here is that it wasn't clear to me how the global update() function was called.

I was able to fix it by importing my update function and then setting:

import __main__
__main__.update = update

I haven't needed to do the same with input, but it looks like it should work the same, as the code that calls update() and input() are similar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant