code: def test_change_is_detected_while_building(self, site_dir, docs_dir):
      before_finished_building = threading.Barrier(2)
      can_finish_building = threading.Event()
  
      def rebuild():
          content = Path(docs_dir, "foo.docs").read_text()
          Path(site_dir, "foo.site").write_text(content * 5)
          before_finished_building.wait(timeout=10)
          self.assertTrue(can_finish_building.wait(timeout=10))
  
      with testing_server(site_dir, rebuild) as server:
          server.watch(docs_dir)
          time.sleep(0.01)
  
          Path(docs_dir, "foo.docs").write_text("b")
          before_finished_building.wait(timeout=10)
          Path(docs_dir, "foo.docs").write_text("c")
          can_finish_building.set()
  
          _, output = do_request(server, "GET /foo.site")
          self.assertEqual(output, "bbbbb")
  
          before_finished_building.wait(timeout=10)
  
          _, output = do_request(server, "GET /foo.site")
          self.assertEqual(output, "ccccc")
  
imports: import contextlib
  import email
  import io
  import sys
  import threading
  import time
  import unittest
  from pathlib import Path
  from unittest import mock
  from mkdocs.livereload import LiveReloadServer
  from mkdocs.tests.base import change_dir, tempdir
label_desc: Use image node_id 9 for calling the BuildTests obj's underlying member method code with example usage: obj.test_change_is_detected_while_building(site_dir, docs_dir) without return types