diff --git a/core/modules/file/lib/Drupal/file/Tests/DownloadTest.php b/core/modules/file/lib/Drupal/file/Tests/DownloadTest.php
index 4fde332f7f1b46fe51efb66fba5d53518371dd07..fe48c05dacb28304d2e1066440a3f051c96b292b 100644
--- a/core/modules/file/lib/Drupal/file/Tests/DownloadTest.php
+++ b/core/modules/file/lib/Drupal/file/Tests/DownloadTest.php
@@ -105,7 +105,6 @@ function testFileCreateUrl() {
       'clean' => '',
       'unclean' => 'index.php/',
     );
-    $generator = $this->container->get('url_generator');
     foreach ($clean_url_settings as $clean_url_setting => $script_path) {
       $clean_urls = $clean_url_setting == 'clean';
       $request = $this->prepareRequestForGenerator($clean_urls);