Thanks to visit codestin.com
Credit goes to github.com

Skip to content
/ pyglet Public
forked from pyglet/pyglet

pyglet is a cross-platform windowing and multimedia library for Python, for developing games and other visually rich applications.

License

Notifications You must be signed in to change notification settings

sannedb/pyglet

 
 

Repository files navigation

Report for Assignment 1

Project chosen

Name: pyglet

URL: https://github.com/pyglet/pyglet

Number of lines of code and the tool used to count it: 100531, calculated by Lizard: Screenshot 2024-06-27 at 11 42 34

Programming language: Python

Coverage measurement

Existing tool

We used Coverage (coverage.py) as recommended by the coordinators. Pyglet instructed to only run the unit tests by calling pytest on their tests/unit directory, so we did just that. The commands to execute the tests were as follows:
# installing necessities
python3 -m pip install coverage
pip install --upgrade --user pyglet
pip install -r tests/requirements.txt --user

# running test and gathering results
coverage run --branch -m pytest tests/unit
coverage html

This resulted in the following coverage: Screenshot 2024-06-27 at 13 03 59 Screenshot 2024-06-27 at 13 03 31

Your own coverage tool

Sanne

get_document.py

https://github.com/sannedb/pyglet/commit/b4bc00c405f50ee607d8b7c33ead8e892f292338

Screenshot 2024-06-27 at 14 25 56

handle_answer.py

https://github.com/sannedb/pyglet/commit/b4bc00c405f50ee607d8b7c33ead8e892f292338

Screenshot 2024-06-27 at 14 26 05

Sepaanta

limit.py

https://github.com/sannedb/pyglet/commit/68bec1593026c784580dc821d2a7b42e9738bdf1


normalize.py

https://github.com/sannedb/pyglet/commit/0db04da130f651e0849d77826ba2a974ef476993

Emilija

inverse.py

https://github.com/sannedb/pyglet/commit/50ee8a173c09bc9bbfecc37ad67fdf1ce6cda241

Screenshot 2024-06-27 at 21 49 51

on_key_press.py

https://github.com/sannedb/pyglet/commit/33fbb3e8d2ae0e39e8671a59c7ed0c085571a4b0

Rūta

draw_text.py

https://github.com/pyglet/pyglet/commit/423262dba9547773da371a9ad5f36e63e7455f75

Screenshot 2024-06-27 at 23 23 51

tear_down.py

https://github.com/sannedb/pyglet/commit/cbda5d030a0bf155ae8cc6e51892bb93cca1209c Screenshot 2024-06-27 at 23 24 19

Coverage improvement

Individual tests

Sanne

Test 1: get_document.py

https://github.com/sannedb/pyglet/commit/9e643251d0b8139fafc9ac9fa928f2d5c7a3e1f0

Screenshot 2024-06-27 at 14 25 56

After:

Screenshot 2024-06-27 at 14 32 28

The coverage is now 100%. In essence this was not too hard, because there can only be two situations: one where there is no document so they create one, and one where there is one and they return that. I created tests for both cases. The coverage was improved because it was 0% at first, which I am assuming is because either of the situations will always be true so creating a test for this function may not have had the highest priority for Pyglet's developer team. Below you can find the proof of improvement after checking with coverage.py:


Screenshot 2024-06-27 at 14 52 23 Screenshot 2024-06-27 at 14 53 19

Test 2: handle_answer.py

https://github.com/sannedb/pyglet/commit/9e643251d0b8139fafc9ac9fa928f2d5c7a3e1f0

Screenshot 2024-06-27 at 14 26 05

After:

Screenshot 2024-06-27 at 17 51 18

The coverage for this function is now at 95%. I have created mock situations, that will print statements addressing what the error is, rather than raising the actual error, so that the testing can proceed without the file shutting down. Once again, there was no test made for it to begin with so its initial coverage was at 0%, meaning the coverage would have improved regardlessly even if i were to check just the 'None' situation. Below you can find the proof of improvement after checking with coverage.py:


Screenshot 2024-06-27 at 14 43 51 Screenshot 2024-06-27 at 14 44 18

Sepaanta

Test 1: limit.py

https://github.com/sannedb/pyglet/commit/3e7bc00ec4c81870041557bf3a7075998b088129

old results:




the coverage is now 100% from 0%. There were no tests initially, which makes it easy to improve the coverage. I tested it with border values. One where the check is barely true and one where is barely false.

Test 2: normalize.py


https://github.com/sannedb/pyglet/commit/66b3d38f7262866df85445d3283d81b2109e5069


The coverage is now 100% from 0%. There also weren't existing tests for this function. Which made it easy to improve

Emilija

Test 1: inverse.py

https://github.com/sannedb/pyglet/commit/50ee8a173c09bc9bbfecc37ad67fdf1ce6cda241

Screenshot 2024-06-27 at 21 49 51 Screenshot 2024-06-27 at 17 05 26 Screenshot 2024-06-27 at 20 49 32

The coverage went from 54% to 86%. Because the added test functions (test_inverse_of_zero_matrix and test_inverse_of_all_same_matrix) ensured that the branches in the inverse function were executed during the tests.

Test 2: on_key_press

https://github.com/sannedb/pyglet/commit/33fbb3e8d2ae0e39e8671a59c7ed0c085571a4b0

Screenshot 2024-06-27 at 20 51 03 Screenshot 2024-06-27 at 20 52 13

The coverage went from 0% to 100% because the test function (test_on_key_press_pass) created ensured that the branches in on_key_press were executed.

Rūta

Test 1: draw_text.py

https://github.com/pyglet/pyglet/commit/423262dba9547773da371a9ad5f36e63e7455f75

Screenshot 2024-06-27 at 23 23 51
After:
Screenshot 2024-06-28 at 00 52 57

image image

The coverage went from 0 to 12%

Test 2: tear_down.py

https://github.com/pyglet/pyglet/commit/cbda5d030a0bf155ae8cc6e51892bb93cca1209c

Screenshot 2024-06-27 at 23 24 19
After:
Screenshot 2024-06-28 at 00 53 16

image

image

The coverage went from 20% to 71%

Overall

Screenshot 2024-06-27 at 13 03 59 Screenshot 2024-06-27 at 23 26 48

Statement of individual contributions

Sanne:

  • Tested the NLOC for this document;
  • ran the coverage tool for this document;
  • instrumented and tested coverage for get_document and handle_answers;
  • handled README.md structure.

Sepaanta:

  • Found the project;
  • ran the initial coverage test;
  • instrumented and tested coverage for limit.py and normalize.py

Emilija:

  • Ran the initial NLOC check;
  • Ran initial coverage report;
  • instrumented and tested coverage for inverse and on_key_press;

Rūta:

  • Did draw_text and tear_down

About

pyglet is a cross-platform windowing and multimedia library for Python, for developing games and other visually rich applications.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 96.8%
  • CSS 1.8%
  • Other 1.4%