coveralls: 
[![Coverage Status](https://coveralls.io/builds/27058680/badge)](https://coveralls.io/builds/27058680)

Coverage remained the same at 100.0% when pulling **499de4205b2c7e941b389efa27d52b3ed98a7cf0 on Thetwam:issue/303-submissions-key-missing** into **34ecd3ee222d74bf552d28339b6beff75ccd6c27 on ucfopen:develop**.

diff --git a/canvasapi/submission.py b/canvasapi/submission.py
index 588a24a..15df324 100644
--- a/canvasapi/submission.py
+++ b/canvasapi/submission.py
@@ -179,17 +179,16 @@ class Submission(CanvasObject):
 @python_2_unicode_compatible
 class GroupedSubmission(CanvasObject):
     def __init__(self, requester, attributes):
+        super(GroupedSubmission, self).__init__(requester, attributes)
+
         try:
             self.submissions = [
                 Submission(requester, submission)
                 for submission in attributes["submissions"]
             ]
-            del attributes["submissions"]
         except KeyError:
             self.submissions = list()
 
-        super(GroupedSubmission, self).__init__(requester, attributes)
-
     def __str__(self):
         return "{} submission(s) for User #{}".format(
             len(self.submissions), self.user_id

GroupedSubmission 'submissions' key:value deleted
# Describe the bug

In #280 we added the first instance of nesting a list of one type of object inside another. While this generally works well, there is a small side effect: The `'submissions'` key:value pair is removed from the `attributes` dict. This is potentially misleading, since one of the uses of calling `attributes` is to see what data was originally used to create the object (via `.to_json()`).

`'submissions'` being removed may give the (incorrect) impression that submissions were never returned from Canvas.


# To Reproduce

Steps to reproduce the behavior:

1. Create a `GroupedSubmission` object with nested submissions
2. Print the attributes of the created object (`print(grouped_submission.attributes)`)
3. Observe that there is no `'submissions'` key:value pair

# Expected behavior

`'submissions'` should be visible in the printed attributes, to assist in debugging.

# Environment information

- Python version (`python --version`)
3.7+

- CanvasAPI version (`pip show canvasapi`)
0.14.0

# Additional context

This is somewhat related to #56, as we'll need to be careful about deleting keys in the future.

diff --git a/tests/test_submission.py b/tests/test_submission.py
index ffe0731..0bbe318 100644
--- a/tests/test_submission.py
+++ b/tests/test_submission.py
@@ -154,6 +154,29 @@ class TestGroupedSubmission(unittest.TestCase):
         self.assertIsInstance(grouped_submission.submissions, list)
         self.assertEqual(len(grouped_submission.submissions), 0)
 
+    def test__init__issue_303_regression(self):
+        """
+        Regression test for issue #303
+        https://github.com/ucfopen/canvasapi/issues/303
+        """
+        grouped_submission = GroupedSubmission(
+            self.canvas._Canvas__requester,
+            {
+                "user_id": 1,
+                "submissions": [
+                    {
+                        "id": 1,
+                        "assignments_id": 1,
+                        "user_id": 1,
+                        "html_url": "https://example.com/courses/1/assignments/1/submissions/1",
+                        "submission_type": "online_upload",
+                    }
+                ],
+            },
+        )
+        self.assertTrue(hasattr(grouped_submission, "submissions"))
+        self.assertIn("submissions", grouped_submission.attributes)
+
     # __str__()
     def test__str__(self):
         string = str(self.grouped_submission)

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest coverage flake8 requests-mock
apt-get update apt-get install -y gcc
3.6
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
attrs==22.2.0
-e git+https://github.com/ucfopen/canvasapi.git@8bd85663a2a91cf2ec37de431257ab80ce8e7d57#egg=canvasapi
certifi==2021.5.30
charset-normalizer==2.0.12
coverage==6.2
flake8==5.0.4
idna==3.10
importlib-metadata==4.2.0
iniconfig==1.1.1
mccabe==0.7.0
packaging==21.3
pluggy==1.0.0
py==1.11.0
pycodestyle==2.9.1
pyflakes==2.5.0
pyparsing==3.1.4
pytest==7.0.1
pytz==2025.2
requests==2.27.1
requests-mock==1.12.1
six==1.17.0
tomli==1.2.3
typing_extensions==4.1.1
urllib3==1.26.20
zipp==3.6.0

name: canvasapi
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - attrs==22.2.0
      - charset-normalizer==2.0.12
      - coverage==6.2
      - flake8==5.0.4
      - idna==3.10
      - importlib-metadata==4.2.0
      - iniconfig==1.1.1
      - mccabe==0.7.0
      - packaging==21.3
      - pluggy==1.0.0
      - py==1.11.0
      - pycodestyle==2.9.1
      - pyflakes==2.5.0
      - pyparsing==3.1.4
      - pytest==7.0.1
      - pytz==2025.2
      - requests==2.27.1
      - requests-mock==1.12.1
      - six==1.17.0
      - tomli==1.2.3
      - typing-extensions==4.1.1
      - urllib3==1.26.20
      - zipp==3.6.0
prefix: /opt/conda/envs/canvasapi

tests/test_submission.py::TestGroupedSubmission::test__init__issue_303_regression
tests/test_submission.py::TestSubmission::test__str__ tests/test_submission.py::TestSubmission::test_create_submission_peer_review tests/test_submission.py::TestSubmission::test_delete_submission_peer_review tests/test_submission.py::TestSubmission::test_edit tests/test_submission.py::TestSubmission::test_get_submission_peer_reviews tests/test_submission.py::TestSubmission::test_upload_comment tests/test_submission.py::TestSubmission::test_upload_comment_section tests/test_submission.py::TestGroupedSubmission::test__init__no_submission_key tests/test_submission.py::TestGroupedSubmission::test__str__
canvasapi/submission.py
canvasapi/submission.py